Prettier

prettier.io ↗

Format source files with a consistent, opinionated printer that supports common web and configuration languages.

SI Score
80/100
Pricing
Open Source AI reading, not confirmed
Free plan
Not confirmed
Sign-up required
Not confirmed

Ask SI about Prettier

Answers use saved listing facts and recorded sources.
Homepage screenshot
Screenshot of the Prettier homepage

What it does

Prettier is an opinionated code formatter that parses supported files and prints them using consistent formatting rules. Its official documentation lists JavaScript, TypeScript, JSX, HTML, CSS, JSON, GraphQL, Markdown, and YAML among its supported languages. Teams can add it to a project, set shared configuration, and run it locally or in continuous integration. It reformats supported files without checking the program's code-quality rules or correcting its logic.

Make formatting repeatable

Install Prettier as a pinned development dependency in the repository so editors, local scripts, and CI use the same version. The official install guide recommends adding a configuration file and a .prettierignore file; the configuration can stay small because Prettier deliberately offers a limited set of formatting options. A useful first pass is to format a few files, inspect the diff, and agree on the output before applying it to a larger tree.

The CLI provides separate modes for editing and checking files. The documented --write option rewrites supported files in place, while --check reports files whose formatting differs. For example, a team can run prettier . --write locally and use prettier . --check in CI to detect an unformatted commit without rewriting it during the check. These are illustrative commands from the documentation, not commands run here.

Prettier is a formatter, not a replacement for linter rules that check code quality. Its rationale states that it reformats code without changing behavior, so a successful formatting check does not show that the program is correct. Its opinionated output can differ from a project's existing style, so teams should review the first formatting diff. The project is MIT-licensed.

Strengths

  • The formatter supports a broad set of code and documentation formats, including JavaScript, TypeScript, CSS, JSON, Markdown, and YAML.
  • A pinned project dependency can keep local formatting and CI checks on the same Prettier version.
  • The CLI separates file rewriting from check-only use in CI.

Watch out for

  • The opinionated formatter changes existing whitespace and line wrapping, so teams should review the initial diff and agree on the output.
  • Formatting checks do not cover code-quality rules such as unused-variable checks, so a linter remains useful alongside Prettier.

Best for

  • Teams standardizing formatting across several supported programming and configuration languages
  • Repositories that want repeatable local formatting and non-mutating CI checks

Sources