If You’re Not Using Prettier, You’re Probably Writing Ugly Code

Posted by

Your code might work, but without consistent formatting, it’s still hard to read, hard to maintain, and harder to love.

Your code might work, but without consistent formatting, it’s still hard to read, hard to maintain, and harder to love.

Introduction

You can tell a lot about a developer by how their code looks.

Some developers write clean, consistent code, every line neatly aligned, indentation flawless, quotes matching, no trailing spaces, and line breaks where they belong.

Others… not so much.

They might be great at logic, but their code looks like it was written during an earthquake.

And that’s where Prettier comes in.

Prettier isn’t just another tool. It’s a developer sanity saver, an opinionated code formatter that automatically makes your code look like it was written by a team of perfectionists.

In this post, you’ll learn:

  • What Prettier is and why it matters
  • The real problems it solves (that you didn’t know you had)
  • How to set it up in your project
  • How to integrate it with VS Code and Git
  • And how it keeps your team’s code consistent forever

1. What Is Prettier, Really?

Prettier is an opinionated code formatter.

That means it automatically reformats your code every time you save a file, ensuring consistent spacing, indentation, and syntax styling across your entire codebase.

It supports almost every modern language and framework, including:

  • JavaScript, TypeScript
  • HTML, CSS, SCSS
  • JSON, Markdown, YAML
  • React, Vue, Angular, Svelte

And it integrates seamlessly with editors like VS Code, WebStorm, Vim, Sublime, and more.

Basically:

You write the code.
Prettier fixes how it looks.


2. Why Formatting Actually Matters

Many developers underestimate formatting after all, code still runs, right?

But here’s the problem: humans read code more than machines do.

Badly formatted code hurts collaboration and slows down your brain.

Let’s look at an example.

❌ Before Prettier

function getUserData(id){return fetch(`/api/users/${id}`).then(r=>r.json()).then(d=>{console.log(d);return d;});}

✅ After Prettier

function getUserData(id) {
return fetch(`/api/users/${id}`)
.then((r) => r.json())
.then((data) => {
console.log(data);
return data;
});
}

Both do the same thing.
 But one makes you question your life choices.

Prettier fixes inconsistency, indentation, and readability, so you and your teammates can focus on logic instead of spacing wars.


3. The Real Problem: Inconsistent Style

Let’s say you’re working with a team of five developers.

  • One prefers a single quote.s '.
  • Another insists on double quotes. ".
  • One uses 2 spaces for indentation.
  • Another uses tabs.
  • Someone adds semicolons, someone doesn’t.

The result?
Your Git history looks like a battlefield.

You waste time reviewing pull requests full of formatting noise instead of logic changes.

Prettier eliminates all of that.
It enforces one consistent style, no matter who writes the code.


4. Installing and Using Prettier

Setting up Prettier is easier than you think.

Step 1: Install Prettier

npm install --save-dev prettier

Step 2: Create a .prettierrc file

This file defines your preferred formatting rules.

{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"printWidth": 100,
"trailingComma": "es5"
}

Now every time Prettier runs, it follows these rules.

Step 3: Format Your Code

To format your files manually:

npx prettier --write .

This will scan your entire project and auto-format every supported file.


5. Integrate with VS Code

If you’re using Visual Studio Code, it’s even simpler.

1. Install the Prettier Extension

Search for “Prettier Code Formatter” in the Extensions panel.

2. Enable Format on Save

In VS Code settings, add:

{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}

Now, every time you hit Save, your code auto-formats like magic.

No more Ctrl + Shift + F dance.


6. Enforce Prettier with ESLint

Prettier and ESLint work beautifully together. ESLint catches logic and syntax errors, while Prettier fixes your formatting.

To integrate them:

npm install --save-dev eslint-config-prettier eslint-plugin-prettier

Then update your .eslintrc File:

{
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}

Now ESLint will warn you when your code doesn’t match Prettier’s rules and even fix it automatically.


7. Use Prettier with Git Hooks

You can also set up pre-commit hooks so no ugly code ever enters your repository.

Install Husky and Lint-Staged:

npm install --save-dev husky lint-staged

Add these to your package.json:

{
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,ts,jsx,tsx,css,html,json,md}": "prettier --write"
}
}

Now, every time someone commits, Prettier automatically formats their staged files before they go into Git.

No more messy diffs or inconsistent PRs.


8. Why Teams Love Prettier

Here’s what changes when you start using Prettier in a team:

  • No more style arguments, Prettier decides for you.
  • Code reviews are cleaner focus shifts to logic, not formatting.
  • Code looks uniform even across different contributors.
  • Saves hours weekly, no manual formatting ever again.

It’s like having a robot that keeps your code beautiful 24/7.


9. Common Myths About Prettier

❌ “It’ll mess up my style.”

Nope. Prettier is configurable. You can customize line width, quotes, semicolons, and tabs.

❌ “It slows down my editor.”

Not true formatting happens in milliseconds.

❌ “My IDE already does that.”

Your IDE might auto-indent or reformat, but only Prettier enforces consistent, opinionated rules across the entire project and team.


10. The Bigger Picture

Prettier isn’t just about making your code look nice; it’s about discipline, consistency, and scalability.

When you return to a file months later, you don’t have to guess who wrote it because everyone’s code looks identical.

And that’s a good thing.

Your future self (and your teammates) will thank you for using Prettier.


Conclusion

Let’s be honest, st messiest code is hard to maintain, even if it works perfectly.

Prettier fixes that problem forever.
It standardizes your code style so you can spend less time debating spaces and semicolons and more time actually building cool things.

If you’re not using it yet, install it today.
Because beautiful, consistent code isn’t optional, it’s a mark of professionalism.

Pro Tip: Turn on “Format on Save” and forget about formatting forever.


Call to Action

Do you already use Prettier in your workflow?
Share your setup or team experience in the comments and bookmark this post for your next project setup checklist.

Leave a Reply

Your email address will not be published. Required fields are marked *