Build a .prettierrc that matches your team’s style
Prettier is an opinionated formatter, but it still exposes a handful of options
that teams disagree on — line width, quotes, semicolons, trailing commas. A
.prettierrc file pins those choices so every contributor’s editor formats
identically. This builder lets you set each option and shows a live preview of
how a sample snippet reformats, then emits clean JSON.
How it works
Prettier reformats code by parsing it into an abstract syntax tree and
re-printing it, discarding your original whitespace entirely. Your .prettierrc
only tweaks the printer’s decisions. The most impactful option is printWidth:
Prettier tries to keep each line under that width and breaks long expressions
onto multiple lines when they would exceed it. A typical config looks like:
{
"printWidth": 100,
"tabWidth": 2,
"singleQuote": true,
"semi": true,
"trailingComma": "all",
"arrowParens": "always"
}
trailingComma: "all" is preferred today because adding a new line to an array
or argument list touches only that one line in git, instead of also editing the
previous line to add a comma. The live preview in this tool runs the same
decisions Prettier would make on a small sample so you can sanity-check before
committing.
Tips and notes
- Wider
printWidth(100–120) reduces awkward line breaks on modern displays; 80 remains the conservative default. - Pair Prettier with
eslint-config-prettierso ESLint stops reporting formatting issues Prettier already handles. - Add a
.prettierignorefor build output and vendored files so Prettier does not rewrite generated code. - Run
prettier --write .once to reformat the whole repo, then commit that as a single “apply prettier” change so future diffs stay clean.