🔧
Build Tool35M+/wkMIT

prettier

Prettier is an opinionated code formatter that enforces a consistent code style across your entire codebase by parsing and re-printing code with its own rules.

Installation

npm
npm install -D prettier
yarn
yarn add -D prettier
pnpm
pnpm add -D prettier

Import

ESM
import * as prettier from 'prettier';

Quick Example

usage
// .prettierrc
{
  "semi": true,
  "singleQuote": true,
  "trailingComma": "all",
  "printWidth": 100,
  "tabWidth": 2
}

// CLI: npx prettier --write .

About prettier

Prettier is an opinionated code formatter that enforces a consistent code style across your entire codebase by parsing and re-printing code with its own rules. Unlike linters that warn about style issues, Prettier automatically reformats code, eliminating all style-related discussions in code reviews. Prettier supports JavaScript, TypeScript, JSX, TSX, CSS, SCSS, Less, HTML, JSON, GraphQL, Markdown, YAML, and more through its built-in parsers and community plugins. The tool deliberately offers few configuration options — print width, tab width, tabs vs spaces, semicolons, quotes, trailing commas, bracket spacing, and a few others — enforcing a consistent style that most teams can agree on without debate. Prettier integrates with all major editors through extensions that format on save, and with CI pipelines through the --check flag that verifies formatting without modifying files. Prettier works alongside ESLint using eslint-config-prettier to disable ESLint style rules that conflict with Prettier's formatting. The tool has become essentially universal in the JavaScript ecosystem, with most popular open-source projects and companies adopting it as their standard formatter.

Quick Facts

Packageprettier
CategoryBuild Tool
Weekly Downloads35M+
LicenseMIT
Installnpm install -D prettier

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.