What is Prettier? Why is Prettier needed?
Prettier is an automatic code formatter. It does not check code for errors, it brings it to a consistent, neat, and readable form according to predefined rules.
Why it is needed
Prettier solves several tasks at once:
A consistent code style across the project A team can write differently (some add spaces, some don't, some write on one line, some on three), and Prettier automatically brings everything to one style.
Saving time
There is no need to manually argue about brackets, indentation, or line breaks. Press Format, and everything is in order.
Readability and cleanliness of code Formatted code is easier to read, maintain, and change.
Getting rid of "clutter" Prettier fixes indentation, line breaks, quotes, line length, and so on, by itself.
How Prettier differs from ESLint
| Tool | What it does |
|---|---|
| ESLint | Looks for errors and bad practices in JavaScript/TypeScript |
| Prettier | Formats code (style, line breaks, indentation, quotes) |
They are often used together: ESLint → checks | Prettier → aligns the code
Where it is used
Prettier works for most file types:
- JavaScript / TypeScript
- HTML, CSS, SCSS
- JSON
- Markdown
- JSX / TSX
- YAML
Summary
Prettier is needed to automatically format code and make it consistent, clean, and easy to read. It is a tool for convenience, cleanliness, and discipline in a project, especially in team development.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.