Prettier

Prettier

Prettier is an opinionated code formatter that enforces a consistent style across your entire codebase. It supports JavaScript, TypeScript, CSS, HTML, JSON, Markdown, YAML, and many more languages, integrating seamlessly with editors, pre-commit hooks, and CI pipelines. By automatically formatting code on save, Prettier eliminates debates over style and lets development teams focus on what truly matters — logic and architecture.

Key Features

  • Opinionated by design — Minimal configuration options that eliminate bike-shedding over code style in code reviews
  • Multi-language support — JavaScript, TypeScript, JSX/TSX, Flow, CSS/SCSS/Less, HTML, JSON, Markdown, YAML, GraphQL, and more
  • Editor integration — Native support in VS Code, JetBrains IDEs, Sublime Text, Vim, Emacs, and most editors
  • Pre-commit hooks — Seamless integration with husky and lint-staged for auto-formatting before every commit
  • CLI and API — Command-line tool for batch formatting with glob patterns and programmatic API for custom tooling
  • Customisable config — .prettierrc file or editor settings for print width, tab width, quotes, semicolons, and trailing commas
  • Markdown and YAML formatting — Consistent table alignment, list formatting, and YAML value alignment
  • Embedded language detection — Correctly formats JS inside HTML, CSS-in-JS, and GraphQL inside JavaScript strings

Why Use Prettier?

Prettier eliminates stylistic disagreements from code reviews. Instead of commenting on formatting, reviewers can focus on logic and architecture. It’s the industry standard for code formatting, adopted by companies like Airbnb, Google, and Microsoft across their open-source projects, and used by millions of developers worldwide.

Use Cases

  • Teams standardising on a single code style across large codebases
  • Pre-commit hooks that auto-format before every commit for consistent history
  • CI pipelines that enforce formatting consistency and fail on style violations
  • Large codebases being migrated to consistent formatting (Prettier supports gradual adoption)
  • Open-source projects with many contributors needing unified code style

Platform

Node.js (npm/pnpm/yarn) · CLI · VS Code extension · Editor plugin

Licence

MIT Licence — open source

Website

prettier.io

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.