# Prettier

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

**Field:** Software Development  
**Category:** Editors & Tools  
**Also known as:** Prettier Formatter, prettier --write

## Think of it like

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

## 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

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

## Example code

```console
$ npx prettier . --write
```

One command tidies each file in this folder, and in the ones below it.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [Code Formatter](https://learn.benibix.com/term/development/formatter)
- [Linter](https://learn.benibix.com/term/development/linter)
- [ESLint](https://learn.benibix.com/term/development/eslint)
- [Code Review](https://learn.benibix.com/term/development/code-review)
- [JavaScript](https://learn.benibix.com/term/development/javascript)

## Told apart from

- [Prettier vs ESLint](https://learn.benibix.com/compare/prettier-vs-eslint): People think Prettier and ESLint do the same job, and they do not. Prettier only changes how code looks: the spaces, the quotes and the line breaks. ESLint looks for code that may be wrong, like a name you set but never use. Most teams run both. Prettier sets the look, and ESLint hunts for bugs.

## Taught in

- [Linters and Formatters](https://learn.benibix.com/learn/development-tools/linters-and-formatters): Coding Tools, 4/13

![On the left, three lines of JavaScript with odd spaces, mixed quotes and an if block squeezed onto one line. An arrow marked prettier --write points to the right, where the same code has even spacing, double quotes, semicolons and the if block opened onto three lines.](https://learn.benibix.com/diagrams/dev5-prettier.svg)

---

Source: https://learn.benibix.com/term/development/prettier
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
