PACKAGE · LINTING & FORMATTING

prettier

Prettier is an opinionated code formatter

WEEKLY DOWNLOADS 54.1M
STARS 51.9K
FORKS 4.7K
OPEN ISSUES 1.4K
GZIP SIZE 33.5 kB
UNPACKED SIZE 8.6 MB
DEPENDENCIES 1
LAST UPDATED 4mo ago
DOWNLOAD TRENDS

prettier downloads — last 12 months

Download trends for prettier1 download series from Jun 2025 to May 2026. Use left and right arrow keys to inspect monthly values.0109.9M219.8M329.8M439.7MJun 2025SepDecMarMay 2026
prettier
ABOUT PRETTIER

Prettier is an auto-formatter that enforces a consistent code style across a codebase. It solves the problem of subjective coding style debates and the time spent manually formatting code, ensuring every developer on a team adheres to the same visual structure. This leads to more readable and maintainable code, reducing cognitive load when reviewing or working on different parts of a project.

Its core philosophy centers on being opinionated, meaning it makes decisions about code formatting so developers don't have to. The primary audience includes JavaScript, TypeScript, CSS, and related language developers who value consistency and wish to automate the formatting process. It aims to eliminate stylistic differences and focus developer effort on feature development rather than code aesthetics.

Prettier's API allows integration into various development workflows. It can be run programmatically using `prettier.format()` to format strings or files, accepting options to customize its behavior, though it encourages minimal configuration. The core mechanism involves parsing code into an Abstract Syntax Tree (AST), manipulating it according to its rules, and then regenerating code, ensuring syntactically correct output.

Integration points are broad, supporting numerous languages and file types including JavaScript, TypeScript, Flow, JSX, TSX, JSON, CSS, SCSS, Less, HTML, Vue, Angular, and Markdown. It easily fits into pre-commit hooks via tools like Husky and lint-staged, CI/CD pipelines for automated checks, and editor integrations for real-time formatting on save.

With 84.8 million weekly downloads and extensive community backing, Prettier is a mature and stable tool. Its unpacked size of 8.6 MB and gzipped bundle size of 33.5 kB indicate it is a relatively lightweight dependency for the value it provides. The focus on a single formatting style minimizes complexity and potential conflicts with other code processing tools.

While Prettier aims for comprehensive formatting, it does not enforce linting rules like detecting unused variables or problematic patterns. Developers needing these checks should integrate a separate linter like ESLint. Additionally, Prettier's opinionated nature means it may override personal or team preferences on certain stylistic choices, requiring a team consensus to adopt its defaults.

WHEN TO USE
  • When you need to automatically enforce a consistent code style across a JavaScript, TypeScript, or CSS codebase.
  • When running Prettier programmatically using `prettier.format()` to format code blocks within an application.
  • When integrating with pre-commit hooks using Husky and lint-staged to format staged files before commits.
  • When setting up CI/CD pipelines to ensure all pushed code adheres to predefined formatting standards.
  • When developers on a team have differing stylistic preferences and you want to eliminate formatting debates.
  • When you need to format files beyond JavaScript, such as HTML, CSS, JSON, Markdown, or GraphQL.
WHEN NOT TO USE
  • If your primary need is to enforce code quality rules like detecting unused variables or potential errors; use a dedicated linter instead.
  • If you require fine-grained control over every aspect of code formatting and prefer manual styling; Prettier's opinionated nature restricts deep customization.
  • If you are working in an environment where introducing automated formatting is not feasible due to team resistance or existing complex tooling.
  • If you only need to format very specific, non-standard file types not explicitly supported by Prettier; manual formatting or a specialized tool might be necessary.
  • If your project exclusively uses a language or syntax not covered by Prettier's parser ecosystem; consider alternative formatters or manual processes.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 4
prettier vs oxlint ★ 21.5K · 3.9M/wk prettier vs dprint-node ★ 491 · 662.8K/wk prettier vs @biomejs/biome ★ 24.9K · 4.5M/wk prettier vs eslint ★ 27.3K · 67.4M/wk