Prettier: An Opinionated Formatter That Removes Style Debates from Code Review
Prettier is an opinionated formatter that reprints JavaScript, TypeScript, CSS, HTML, Markdown, and more in one consistent style, and runs in editors, git hooks, or CI.
At a glance
- What is it?
- Prettier is a widely adopted code formatter for JavaScript, TypeScript, CSS, HTML, and more. It reprints code according to fixed rules, making style arguments in pull requests obsolete, but its rigidity is a trade-off.
- Who is it for?
- Adopt Prettier if you want to eliminate style debates and enforce a consistent format across a team or project, and you accept its fixed rules. Do not adopt it if you need fine-grained control over formatting details or if your codebase relies on specific stylistic choices that Prettier does not support.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
What Problem Prettier Solves and Who Should Use It
Prettier addresses a recurring problem in software teams: arguments over code style. Every developer has their own preference for where to break a line, whether to use single or double quotes, and how to indent. These debates consume review time and create inconsistent code. Prettier removes that by being opinionated. It does not offer a hundred options; it offers a default style that is reasonable and consistent. The target audience is any team writing JavaScript, TypeScript, Flow, JSX, JSON, CSS, SCSS, Less, HTML, Vue, Angular, GraphQL, Markdown, or YAML. It is especially useful for projects with multiple contributors, where style drift is common. The README states it can be run in an editor on-save, in a pre-commit hook, or in CI. That covers local and automated enforcement. The core promise is that developers never have to post a nit-picky comment on a code review about formatting again. That is a concrete win for teams that value velocity over stylistic autonomy.
The Parsing and Reprinting Mechanism
Prettier works differently from a search-and-replace tool. According to the README, it parses your code and then re-prints it with its own rules. That is the key architectural decision. It does not apply regex patches; it builds an abstract syntax tree from your source, then serializes that tree back to text. The rules take the maximum line length into account, wrapping code when necessary. The example in the README shows a long function call being broken into multiple lines, each argument on its own line, with a trailing comma. That output is deterministic: the same input always produces the same output, regardless of the original formatting. This mechanism is what makes Prettier reliable across a codebase. Because it parses, it can handle nested structures like JSX and template literals without losing meaning. The trade-off is that the parser must understand every language construct. If a language version introduces a new syntax, Prettier must update its parser. The README lists supported languages, and plugins extend that list, but the core mechanism remains parse-and-reprint.
Getting Prettier Running: Installation and CLI Use
The README points to the documentation for installation, options, CLI, and API, but it does not give exact commands. The homepage and npm package name suggest installation via npm: npm install --save-dev prettier. The CLI is invoked as prettier with a file or directory argument. Common flags include --write to overwrite files and --check to verify formatting without changing anything. The documentation, which is linked but not reproduced here, covers configuration files like .prettierrc and options such as printWidth, tabWidth, and semi. The README mentions a playground at prettier.io/playground, which is a web interface to try formatting without installing anything. For editor integration, the README references on-save hooks, and for pre-commit it links to a guide. A minimal setup would be: add Prettier as a dev dependency, create a .prettierrc file with your few chosen settings, and run prettier --write . to format the whole project. The actual commands are not in the README, so the exact syntax must be confirmed from the official docs.
Real Limitations: When Prettier Is the Wrong Tool
Prettier is not a formatter for every situation. Its opinionated nature means you cannot tweak the output to match a specific style that is not in its option set. For example, it has a limited set of options, and many stylistic choices are hardcoded. If your team has a strong preference for a particular comma style or a specific way to wrap function calls that differs from Prettier's default, you will be fighting the tool. Also, Prettier parses code, so it cannot handle invalid syntax. If you are in the middle of writing code with syntax errors, Prettier will fail until the code is valid. That is a practical limitation in an editor on-save scenario. Additionally, Prettier does not format everything: it does not touch string content or comments, so those can still be inconsistent. The README does not list these limitations, but they are inherent to the parse-and-reprint approach. For projects that need to preserve a specific formatting style for legacy reasons, or where developers want control over every line break, Prettier is the wrong tool.
Alternatives: How Other Formatters Differ
The main alternative to Prettier is a linter with auto-fixing, such as ESLint with its --fix flag. ESLint is not a formatter; it is a linter that checks for errors and enforces stylistic rules, but its auto-fix only applies to specific rules. The difference in approach is substantial. ESLint works on a rule-by-rule basis, letting you configure each rule individually, such as quote style or indent size. Prettier, in contrast, has a global style and only a few options. That means ESLint gives you granular control but requires you to configure dozens of rules to achieve consistency. Prettier gives you consistency out of the box but at the cost of control. Another difference is that ESLint's parser is also pluggable, but its formatting fixes are often partial, not a full reprint. For example, ESLint might fix indentation but not line wrapping. Prettier reprints the entire file, so the output is always complete. If you want to keep using ESLint for code quality rules, you can use Prettier alongside it, letting Prettier handle formatting and ESLint handle logic. That is a common setup, but it means two tools in your pipeline.
Maintenance and Upgrade Cost
Prettier is an actively maintained project, with recent releases in 2026: 3.9.4, 3.9.5, and 3.9.6. The release cadence suggests regular bug fixes and updates. The license is MIT, which means you can use it in commercial projects without restrictions, and you can modify it if needed, though the project does not require you to share changes. The maintenance cost for a user is low: you install it as a dev dependency and update it periodically. However, upgrading Prettier can change the output of your codebase because new versions may adjust formatting rules. That is a real cost. When you upgrade, you may need to run Prettier on your entire codebase again, which can create large diffs. The README does not mention a change log or migration guide, but the documentation likely covers breaking changes. The project's default branch is main, and it is not archived, indicating ongoing support. For a team, the maintenance burden is mostly on the initial setup and on handling version upgrades that alter formatting. The benefit is that once configured, Prettier runs automatically, reducing the need for manual style reviews.
The Opinionated Trade-Off: Consistency Over Flexibility
Prettier's core value is its opinionated nature. The README says it 'enforces a consistent style by parsing your code and re-printing it with its own rules.' That is a direct statement of the trade-off. You give up the ability to customize the output in exchange for not having to decide. For many teams, that is a good deal. The example in the README shows a long function call being reformatted to a multi-line structure. That is a typical case where developers might disagree on the best wrapping. Prettier decides for you. The downside is that you cannot deviate from its choices without turning off the tool. Some teams find that frustrating when they want a specific style, like a different indentation size or a different quote style. Prettier has options for some of those, but not all. The README does not enumerate the options, but the documentation does. The point is that Prettier is not a compromise tool; it is a tool that forces a single style. That is its strength and its limitation. If you accept that, you get consistency. If you do not, you will be constantly fighting the tool.
Editorial conclusion
Adopt Prettier if you want to eliminate style debates and enforce a consistent format across a team or project, and you accept its fixed rules. Do not adopt it if you need fine-grained control over formatting details or if your codebase relies on specific stylistic choices that Prettier does not support. Before adopting, verify that Prettier supports all languages and syntax versions in your stack, test the output against your existing code, and check the option set to see if any of the few available settings (like printWidth or tabWidth) meet your needs. Prettier's value is in its rigidity: it is not a configurable formatter, and that is exactly why it works.
Community notes