prettier downloads · last 12 months
Prettier is an opinionated code formatter that rewrites source files into a consistent style. It addresses formatting differences across a team by applying the same rules to supported code, rather than asking developers to align indentation, line breaks, or spacing by hand.
Its design prioritizes consistent output over extensive stylistic configuration: developers provide source code and formatting options, and Prettier determines the layout. This makes it suitable for teams that want formatting decisions to be automated and reviewed separately from choices about code behavior. Its listed topics include JavaScript, TypeScript, JSON, CSS, HTML, GraphQL, Markdown, and several framework-related formats.
Prettier can be used through its JavaScript API, including `format` to format source text and `check` to test whether text matches the formatter's output. Options such as `parser` identify the language syntax to process, while `filepath` can help select a parser based on a file's name. For repository-wide use, a common pattern is to run the formatter from a script or editor integration and check its output in automated workflows.
The package fits into JavaScript and web development workflows that include Angular, Vue, JSX, and TypeScript, as well as projects that format CSS, JSON, HTML, GraphQL, YAML, and Markdown. It can be used during editing or in a formatting check before changes are accepted; it handles presentation rather than code-quality analysis or semantic changes. Prettier is listed in the Linting & Formatting category.
The supplied package details report version 3.10.1, an MIT license, an unpacked size of 11.4 MB, and a gzip bundle size of 28.0 kB. The metadata also reports 180.5M weekly downloads, 52.4K GitHub stars, 5.0K forks, 1.5K open issues, and a last-updated date of 2026-11-12. These figures provide scale and maintenance context, but do not by themselves establish runtime performance or compatibility with a particular project.
A key caveat is that opinionated formatting may produce diffs across an existing codebase, particularly when introducing it or changing configuration. Formatting does not replace linting, type checking, tests, or review of behavior, and teams should verify that the chosen parser and settings cover their file types before applying it broadly.
- Standardize JavaScript or TypeScript formatting across contributors by running Prettier over source files and reviewing the resulting changes.
- Format JSON, YAML, Markdown, HTML, CSS, or GraphQL alongside application code so those files follow the same automated workflow.
- Use the JavaScript API's `format` function when a tool or script needs to format source text programmatically.
- Use `parser` to select syntax explicitly when formatting text that cannot be identified reliably from its filename.
- Use `filepath` when formatting file contents and want parser selection to follow the file's extension.
- Add a formatting check to a repository workflow with `check` so unformatted source can be identified without treating formatting as a semantic code review.
- Include JSX, Angular, or Vue files in a shared formatting workflow when the project uses those formats and Prettier supports the relevant syntax.
- Avoid Prettier when the team requires individually customized formatting rules that conflict with its opinionated output; use a formatter that supports the required rule-by-rule control.
- Do not use Prettier as a substitute for detecting correctness, type errors, or code-quality problems; add dedicated linting, type-checking, and test steps.
- Avoid applying it to a syntax or file type that its available parsers do not support; select a formatter designed for that syntax or leave those files out of the formatting command.
- Do not run `format` over files where automated layout changes would obscure a sensitive or behavior-focused diff; format them separately and review the changes independently.
- Avoid adopting it without first checking the repository's existing style expectations, because introducing opinionated output can create broad formatting diffs; stage the rollout and review the changes.
- Do not rely on the reported 28.0 kB gzip bundle size as proof that every integration has a small install or runtime cost; measure the actual dependency and execution path for the intended environment.
CORRECTIONS
Spot wrong data here?Spot wrong data on this page?
A short note helps us fix it.A short note helps us fix it. We read every one; confirmed fixes ship in the next nightly build.
Anonymous · No account · No email back