Skip to content
BENIBIX Learn

Prettier

Development🛠️ Editors & ToolsCode Quality Tools

Also known as Prettier Formatter, prettier --write

A free tool that tidies the layout of code. It works on JavaScript, CSS, HTML and more.

Think of it like

It is like a helper who folds all the clothes the same way. Every pile looks neat.

Example

Lucy and Jack used to fight over quotes in code reviews. Now Prettier runs on save, and every file looks the same.

Why it matters

Reviews can focus on what the code does, not where the spaces go. Every file reads the same.

Definition

Prettier is a free tool that sets the layout of your code for you. It works on JavaScript, TypeScript, CSS, HTML, JSON, Markdown, YAML and more. It reads your code, throws away your spacing, and prints it again in one fixed style. It has very few settings on purpose, so a team stops arguing about tabs and quotes. Most people run it each time they save a file.

Example code

console
$ npx prettier . --write
One command tidies each file in this folder, and in the ones below it.
Prettier takes untidy code and prints it in one neat style.

Common mistake

Running it on only some files, so each change mixes real edits with layout edits. Run it on the whole project once.

Key takeaways

  1. 1
    One style. It prints all code the same way.
  2. 2
    Few settings. Less to argue about, on purpose.
  3. 3
    Run on save. Then nobody has to think about it.

Compare

Learn it properly