Prettier vs ESLint — Code Formatter vs Code Linter, Not a Fair Fight
Prettier makes your code pretty; ESLint makes it correct. Pick Prettier for consistency, ESLint for quality—but you need both.
ESLint
ESLint catches bugs and enforces best practices, while Prettier just polishes syntax. Code that looks good but breaks is useless—ESLint prevents that.
They're Not Competitors—They're Teammates with Different Jobs
Prettier is a code formatter that enforces a consistent style—spacing, line breaks, quotes—across your entire codebase. It's opinionated and automatic: you run it, and your code gets prettified, no questions asked. ESLint is a code linter that analyzes your code for potential errors, enforces coding standards, and can even fix some issues automatically. It's configurable and extensible, letting you define rules for your team's specific needs. Comparing them is like comparing a car wash (Prettier) to a mechanic's inspection (ESLint)—one makes it shiny, the other ensures it runs safely.
Where ESLint Wins
ESLint wins because it prevents bugs and enforces quality. It can catch real issues like unused variables, missing return statements, or potential security vulnerabilities. With plugins like eslint-plugin-react or @typescript-eslint, it adapts to modern frameworks and languages. It's not just about style—it's about correctness. Plus, ESLint can auto-fix many issues, saving you from manual cleanup. If you care about code that works, not just looks good, ESLint is non-negotiable.
Where Prettier Holds Its Own
Prettier excels at eliminating style debates. It's zero-config for most setups—install it, run it, and your code is uniformly formatted. This is huge for teams tired of arguing over tabs vs. spaces or line length. It supports 20+ languages out of the box, including JavaScript, TypeScript, CSS, and Markdown. Since it's opinionated, it reduces cognitive load: you don't waste time tweaking settings. For pure formatting consistency, Prettier is unbeatable.
The Gotcha: They Clash on Formatting Rules
If you use both tools without coordination, they'll fight. ESLint has its own formatting rules (e.g., indent or quotes), which can conflict with Prettier's opinions. The fix? Install eslint-config-prettier to disable ESLint's formatting rules, letting Prettier handle style. But this adds setup friction—another dependency to manage. Surprise: some developers skip ESLint entirely, relying on Prettier's limited linting via its --check flag, which is a recipe for buggy code.
If You're Starting Today...
Start with ESLint configured for your project (e.g., using eslint --init), then add Prettier. Use eslint-config-prettier to avoid conflicts. This way, you catch errors early and enforce style later. For a new JavaScript project, install both: npm install eslint prettier eslint-config-prettier --save-dev. Set up ESLint with basic rules, then integrate Prettier. Don't fall for the trap of using Prettier alone—your code will look neat but might be full of hidden issues.
What Most Comparisons Get Wrong
Most comparisons treat this as a choice—it's not. You need both tools. Prettier doesn't replace ESLint because it doesn't catch logic errors or enforce best practices. ESLint doesn't replace Prettier because its formatting rules are configurable and can lead to inconsistency. The real question isn't which to pick, but how to integrate them seamlessly. Ignore hot takes that say one is enough; that's lazy advice from developers who haven't debugged a production issue caused by a missing semicolon.
Quick Comparison
| Factor | Prettier | ESLint |
|---|---|---|
| Primary Purpose | Code formatting—enforces consistent style (spacing, line breaks) | Code linting—catches errors and enforces coding standards |
| Pricing | Free and open-source (MIT license) | Free and open-source (MIT license) |
| Configurability | Low—opinionated with limited options (e.g., printWidth, singleQuote) | High—fully configurable with custom rules and plugins |
| Auto-fix Capability | Yes—formats entire files automatically | Yes—fixes many linting issues automatically |
| Language Support | 20+ languages including JS, TS, CSS, Markdown | 70+ languages via plugins, with core support for JS/TS |
| Integration Complexity | Low—simple setup, often zero-config | Medium—requires rule configuration and plugin management |
| Error Prevention | Minimal—only catches formatting issues | High—catches bugs, security issues, and style violations |
| Community Plugins | Limited—few plugins, mostly for editor integration | Extensive—hundreds of plugins for frameworks like React, Vue |
The Verdict
Use Prettier if: You're on a small team that just wants consistent formatting without debates—Prettier is your quick fix.
Use ESLint if: You're building production software and need to catch bugs early—ESLint is essential for code quality.
Consider: Biome—a newer tool that combines formatting and linting in one, but it's less mature and has limited plugin support compared to ESLint.
ESLint catches bugs and enforces best practices, while Prettier just polishes syntax. Code that looks good but breaks is useless—ESLint prevents that.
Related Comparisons
Disagree? nice@nicepick.dev