Prettier
Opinionated code formatter — ends formatting debates by formatting your code for you.
Pricing
Free / Open source
Type
Automation
Languages
JavaScript, TypeScript, Css, Html
// VERDICT
Reach for Prettier when you want automatic, consistent formatting across the codebase with no bikeshedding. Skip it when you need bug-finding/linting (ESLint) or fine-grained manual formatting control.
Best for
An opinionated code formatter for many languages - it reformats code to one consistent style automatically, ending style debates and keeping diffs clean.
Avoid when
You want a linter that finds bugs (Prettier only formats), or full control over every formatting nuance.
CI/CD fit
npm script · pre-commit (with lint-staged) · CI format check
Languages
JavaScript · TypeScript · Css · Html
Team fit
JS/TS and multi-language teams · Teams ending style debates · QA keeping test code tidy
Setup
Maintenance
Learning
Licence
// BEST FOR
- Automatically formatting code to one consistent style
- Ending style/formatting debates
- Keeping diffs clean and reviewable
- Supporting many languages out of the box
- Running on save, on commit and in CI
- Pairing with ESLint (format + lint)
// AVOID WHEN
- You need bug-finding/linting (ESLint)
- Fine-grained manual formatting control is required
- You want one tool for lint + format
- Your language isn't supported
- A team disagrees with its opinionated style
- You only have trivial formatting needs
// QUICK START
npm install -D prettier
npx prettier --write . # format; use --check in CI; run via lint-staged on commit// ALTERNATIVES TO CONSIDER
| Tool | Choose it when |
|---|---|
| ESLint | You want linting/bug-finding (often run alongside Prettier). |
| lint-staged | You want to run Prettier only on staged files at commit. |
| SonarQube | You want a code-quality platform with gates. |
// FEATURES
- Opinionated formatting — minimal config
- Supports JS/TS, CSS, HTML, JSON, Markdown, YAML, and more
- Editor integrations and pre-commit hooks
- Plugin support for additional languages
- ESLint integration (eslint-config-prettier) to avoid conflicts
// PROS
- Eliminates formatting bikeshedding
- Fast and broadly compatible
- Standard in the JS/TS ecosystem
// CONS
- Opinionated — no toggle for some preferences (e.g., trailing commas)
- Occasional debate about specific output choices
- Plugin ecosystem patchy outside core languages
// EXAMPLE QA WORKFLOW
Install Prettier with a small config
Format on save in the editor
Run via lint-staged on commit
Add a prettier --check CI gate
Integrate with ESLint to avoid conflicts
Keep the tool current