Prettier Explained: Formatting Code So Nobody Argues About It

Introduction

Ask five developers how to format code and you'll get six opinions: tabs or spaces, single or double quotes, semicolons or not, trailing commas or not. Teams have burned entire meetings on these questions — and code reviews full of formatting comments. Prettier ends the argument by removing it: it reformats your code automatically, in one consistent style, every time.

Opinionated by design

Prettier is deliberately opinionated: it offers very few options, and its defaults are the point. Run it on any file and it rewrites the formatting — indentation, quotes, line breaks, trailing commas — to the same style, regardless of who wrote the code:

// Before: inconsistent, hard to scan
function greet( name, greeting ) { return greeting + ", " + name + "!"; }
// After Prettier: one style, every file, every author
function greet(name, greeting) {
  return greeting + ", " + name + "!";
}

It doesn't change what the code does — only how it looks. And because it runs automatically on save or on commit, formatted code is never a thing anyone has to think about or comment on in review.

Prettier vs ESLint: different jobs

Beginners often confuse the two tools from this batch, so the distinction matters: ESLint finds bugs and enforces code quality rules; Prettier only formats. They are designed to work together — ESLint's formatting rules are turned off when Prettier is present, so the tools never fight. The standard setup is both: Prettier makes code look consistent, ESLint makes it correct. One command formats, the other lints, and together they remove an entire category of review comments.

The honest trade

Prettier's opinions won't match everyone's taste — you may hate its line-breaking choices, and there is no option to change most of them. That is the trade, and it is worth it: consistency across a codebase matters more than any individual's preference, and the time saved in reviews and arguments dwarfs the annoyance of an unfamiliar style. Teams that adopt Prettier rarely go back, because the formatting argument simply disappears.

Takeaway

Prettier formats code automatically in one consistent style, ends style arguments by removing the choice, and pairs with ESLint — one formats, the other finds bugs. Adopt both, and code reviews get back to what actually matters: what the code does.

Comments

Popular posts from this blog

Swift Explained: Apple's Language for iPhone, Mac, and More

Flutter Explained: One Codebase, Every Screen

Go Explained: Simple Code That Runs Fast