Prettier formats your code automatically. No more arguing about tabs vs spaces, semicolons, or line length. Save the file, it's formatted.
The Problem Prettier Solves
Code review comment: 'Add a trailing comma here.'
Code review comment: 'Remove the extra newline.'
Code review comment: 'Use single quotes.'
These comments waste time. Prettier eliminates ALL of them by formatting code to a consistent style automatically.
What You Get for Free
Opinionated formatting — few options, consistent output
20+ languages: JavaScript, TypeScript, CSS, HTML, JSON, Markdown, YAML, GraphQL, and more
Editor integration — format on save in VS Code, WebStorm, Vim, Emacs
CI integration — prettier --check fails if code isn't formatted
Git hooks — format only changed files with lint-staged
Quick Start
npm i -D prettier
echo '{}' > .prettierrc
Format everything:
npx prettier --write .
Check in CI:
npx prettier --check .
VS Code Setup
- Install 'Prettier - Code formatter' extension
- Settings:
"editor.formatOnSave": true - Settings:
"editor.defaultFormatter": "esbenp.prettier-vscode"
Now every save = perfectly formatted code.
The Only Config You Need
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"printWidth": 100
}
That's it. Prettier intentionally has few options. Less options = less debates.
With Git Hooks (lint-staged)
npm i -D husky lint-staged
npx husky init
echo 'npx lint-staged' > .husky/pre-commit
// package.json
"lint-staged": {
"*.{js,ts,tsx,css,md}": "prettier --write"
}
Now: commit → only changed files get formatted → commit includes formatted code.
If your team has ANY style discussions in code reviews — install Prettier and never have them again.
Need web scraping or data extraction? Check out my tools on Apify — get structured data from any website in minutes.
Custom solution? Email spinov001@gmail.com — quote in 2 hours.
Top comments (0)