mrkeyoor.com_
Sat 19 Sept 23:47 UTC
npmCLI & Toolingupdated 19 Sept 2026

prettier review

Prettier 3.9.6 parses a supported file and prints a canonical layout, replacing most hand-written spacing and wrapping choices with one repeatable result. Built-in parsers cover JavaScript, TypeScript, JSON, CSS, HTML, Vue, Angular, GraphQL, Markdown, and YAML; plugins add other languages. It is a formatter, so it will not find an unsafe expression or enforce application policy. Version 3.9.6 adds TypeScript import defer syntax, preserves quotes on methods named new, and publishes the official Yuku plugin. The programmatic API remains asynchronous in version 3, including format and configuration lookup.

118.4Mdownloads / wk
Verdict

Prettier 3.9.6 installed as 1 dependency-free package in 0.6 seconds and used 10 MB in our sandbox, with 0 audit findings. Add it when the team wants one enforced print result; skip it when hand-controlled layout is a product requirement.

We installed it

Lab card: what happened when we installed prettierScreenshot of prettier documentation
Install✓ · 0.6s1 package on disk · 10 MB
ImportESM import works · require() works · CommonJS package with exports map
Browser26.3 KBgzipped (79.9 KB minified), bundled with esbuild
TypesTypeScript types bundled
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)

Answers from our run

Does prettier install cleanly?

Yes. In a fresh container with an empty cache, npm install prettier finished in 0.6s, leaving 1 package and 10 MB on disk. npm audit reported no known vulnerabilities.

How much does prettier add to a browser bundle?

26.3 KB gzipped (79.9 KB minified) when the whole package is bundled for the browser with esbuild. Importing only part of it is usually smaller.

Does prettier work with both ESM and CommonJS?

Yes. Both import 'prettier' and require('prettier') worked in Node 22 in our run. The package is published as CommonJS with an exports map.

Does prettier include TypeScript types?

Yes, type declarations ship inside the package, so no @types install is needed.

prettier or @biomejs/biome: which should you use?

@biomejs/biome: Choose it when its supported languages fit and one fast binary should handle both formatting and linting. Prettier 3.9.6 installed as 1 dependency-free package in 0.6 seconds and used 10 MB in our sandbox, with 0 audit findings.

When should you not use prettier?

House style requires exact control over line breaks, alignment, or syntax-specific layout that Prettier deliberately does not expose

API stability4/5The CLI contracts for --write, --check, stdin, ignore files, and configuration lookup remain familiar across version 3. Formatting options change slowly because the project intentionally rejects many new style switches. Programmatic callers had a larger major-version break when APIs became asynchronous and plugin loading changed. Patch 3.9.6 adds syntax and plugin support without altering normal calls, so stable CLI users fare better than custom integrations.
Docs5/5prettier.io documents local installation, editor setup, CLI behavior, configuration formats, ignore rules, every option, plugins, browser standalone use, API calls, staged-file hooks, and migration notes. Examples distinguish a read-only CI check from a mutating write. The option pages explain limitations such as printWidth being a preference rather than a hard cap, which prevents a common configuration mistake and supports a score of 5.
Maintenance5/5The repository is unarchived, was pushed on 2026-08-26, and GitHub reports 1,413 open issues and pull requests. Prettier 3.9.6 shipped on 2026-07-21 with TypeScript import defer parsing, quote preservation for a syntax edge, and an official language plugin. The large queue follows the number of parsers and printer cases, while current pushes and targeted releases show continued work across that surface.
Ecosystem5/5npm counted 132,935,559 downloads for the week ending 2026-08-24, and GitHub reports 52,217 stars. Editors, lint compatibility configs, staged-file runners, CI templates, and language plugins already understand Prettier's config and ignore conventions. A repository-pinned copy can be shared by all of those tools. Plugin compatibility and editor package resolution still need testing, but integration availability is unusually broad.

Discussed on

  1. hnA Prettier JavaScript Formatter498 points
  2. hnPrettier 1.0270 points
  3. hnPrettier 2.0 – Opinionated JavaScript formatter207 points
  4. hnWhy is Prettier rock solid?205 points
  5. hnSpeeding up Prettier locally and on your CI with dprint201 points

Use it if

  • Code review spends time on whitespace, wrapping, quote style, or trailing commas that a printer can settle automatically
  • Editors, staged-file hooks, and CI should all use the same repository-pinned formatter and ignore file
  • One repository contains several supported languages and needs a single formatting command across them
  • The team accepts Prettier's limited options and will isolate the first whole-repository reformat from functional changes
Skip it if

Setup reality

We installed Prettier 3.9.6 in a fresh Node 22 Bookworm sandbox with no cache. npm completed in 0.6 seconds and left exactly 1 package using 10 MB. Prettier declares 0 direct and 0 peer dependencies; the package is 9,876 KB unpacked and MIT licensed. npm audit found 0 known vulnerabilities. It includes TypeScript declarations, uses CommonJS with an exports map, supports require and ESM import, and declares Node 14 or newer.

Pin Prettier as a dev dependency and commit one config plus .prettierignore. Its lookup walks upward from each file, so a monorepo can pick up a parent config unexpectedly. Run the first prettier --write change alone because it can touch nearly every supported file. Generated output, vendored sources, snapshots with meaningful whitespace, and build directories belong in the ignore file.

Version 3 returns promises from format, resolveConfig, getFileInfo, and other JavaScript API calls. Await them and pass filepath when parser inference or overrides matter. Plugins must be loaded explicitly in API and standalone use, and version 3 no longer searches plugin names the same way old wrappers expected. Pin plugin versions beside Prettier and test editor resolution from the workspace.

Our esbuild check of a full-package browser import produced 79.9 KB minified and 26.3 KB gzipped. Standalone browser use also needs the chosen parser plugin and, for JavaScript-family parsers, the estree plugin. In CI use --check, which leaves files untouched and exits nonzero on drift. Reserve --write for developer commands and controlled formatting jobs.

Patterns

Apply the repository's format everywhere format-project

npx prettier --write .

--write edits matching files in place. Keep the first repository-wide formatting diff separate from behavior changes.

Set the few choices the printer allows config-file

{
  "semi": true,
  "singleQuote": true,
  "trailingComma": "all",
  "printWidth": 100
}

printWidth guides line wrapping and does not impose a hard 100-character ceiling on every printed line.

Reject unformatted files without editing them check-in-ci

npx prettier --check .
# exits 1 and lists unformatted files

--check leaves the workspace unchanged and returns a nonzero status when any selected file would be rewritten.

Exclude generated paths and one syntax node ignore-code

# .prettierignore
dist/
coverage/

// in code, skips the next node:
// prettier-ignore
const matrix = [
  1, 0,
  0, 1,
];

A prettier-ignore comment applies to the next parsed node, while .prettierignore removes whole paths from CLI traversal.

Turn off lint rules that conflict with printing eslint-integration

npm i -D eslint-config-prettier

// eslint.config.js
import prettierConfig from 'eslint-config-prettier';
export default [
  // ...your configs,
  prettierConfig,
];

eslint-config-prettier disables conflicting rules. It does not run the formatter or report formatting drift by itself.

Await formatted source in application code api-format

import * as prettier from 'prettier';

const formatted = await prettier.format('const x  =  1', {
  parser: 'babel',
});

Prettier 3 format returns a promise. Provide parser directly or use filepath where parser inference and overrides are needed.

Wrap Markdown with a narrower setting per-filetype-overrides

{
  "printWidth": 100,
  "overrides": [
    {
      "files": "*.md",
      "options": { "proseWrap": "always", "printWidth": 80 }
    }
  ]
}

Overrides are matched using the file path. API callers must supply filepath for these per-language settings to apply.

Format only files staged for commit pre-commit-hook

npm i -D husky lint-staged

// package.json
"lint-staged": {
  "**/*": "prettier --write --ignore-unknown"
}

// .husky/pre-commit
npx lint-staged

--ignore-unknown lets images and unsupported file types pass instead of making a mixed staged set fail.

Infer a parser for piped source format-stdin

prettier --stdin-filepath src/App.tsx < src/App.tsx

stdin has no filename of its own. --stdin-filepath enables parser inference, ignore checks, and matching configuration overrides.

Show which config applies to a file locate-config

npx prettier --find-config-path src/components/Button.tsx

Configuration lookup walks parent directories. This command exposes a surprising monorepo or home-directory config before files are changed.

Check whether Prettier will process a path inspect-file

import * as prettier from 'prettier'

const info = await prettier.getFileInfo('src/generated.ts', {
  ignorePath: '.prettierignore',
})
console.log(info.ignored, info.inferredParser)

getFileInfo is asynchronous in version 3 and reports both ignore status and the inferred parser.

Format TypeScript in a browser bundle browser-standalone

import * as prettier from 'prettier/standalone'
import * as typescript from 'prettier/plugins/typescript'
import * as estree from 'prettier/plugins/estree'

const output = await prettier.format(source, {
  parser: 'typescript',
  plugins: [typescript, estree],
})

Standalone does not discover plugins. TypeScript printing needs both its parser plugin and estree, which adds to the browser payload.

Alternatives

PackageRegistryPick it when
@biomejs/biomenpmChoose it when its supported languages fit and one fast binary should handle both formatting and linting.
dprintnpmChoose it for a formatter host with separately pinned language plugins and different layout choices.
eslintnpmChoose it for JavaScript correctness and policy rules; enable formatting rules only when exact rule-level control is required.

More cli & tooling guides

commander · chalk · typescript · esbuild · yargs · click · the whole shelf →

How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.