Prettier Configuration Options
What you'll learn: How to customize Prettier's formatting behavior using a .prettierrc file to match your team's style preferences.
Understanding Prettier Configuration
Out of the box, Prettier uses sensible defaults—but every team has their own preferences for code style. Should lines be 80 or 120 characters wide? Tabs or spaces? Single or double quotes? The .prettierrc file is where you answer these questions once, ensuring everyone on your team formats code identically.
Think of Prettier configuration like setting the "house rules" for a board game. The game works with standard rules, but your group might prefer specific variations. Once everyone agrees on the rules, you write them down so there's no confusion.
Core Configuration Options
Print Width
{
"printWidth": 80
}
Sets the maximum line length before Prettier wraps code. Common values: 80, 100, or 120.
Tabs vs Spaces
{
"useTabs": false,
"tabWidth": 2
}
useTabs: false means use spaces. tabWidth controls how many spaces (or how wide a tab appears).
Quote Style
{
"singleQuote": true
}
true = single quotes ('hello'), false = double quotes ("hello"). Default is double.
Semicolons
{
"semi": true
}
true adds semicolons at statement ends, false omits them where possible.
Complete Example
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true
}
Key Takeaway: The .prettierrc file lets you configure Prettier's formatting rules for print width, indentation style, quote types, and semicolon usage—ensuring consistent code style across your entire team without debate.