Skip to main content

What does Prettier do to code?

Prettier brings code to a consistent, neat, and readable form according to strictly defined formatting rules. It does not ask for your opinion, it simply rewrites the code automatically in the chosen style.


What Prettier specifically does

It automatically:

  • aligns indentation
  • adds or removes semicolons
  • picks a quote style - ' or "
  • wraps long lines
  • places spaces where needed
  • formats brackets correctly { } ( ) [ ]
  • formats objects, arrays, functions
  • creates a consistent style across the whole project

What this looks like

Before:

js
const user={name:"Tom",age:20} function sayHi(){console.log("Hello")}

After (with Prettier):

js
const user = { name: "Tom", age: 20 }; function sayHi() { console.log("Hello"); }

The main point of Prettier

Without PrettierWith Prettier
Everyone writes "their own way"All files look the same
Team arguments about styleNo arguments, there are rules
Formatting by handCtrl+S → clean code

What it does not do

  • does not check for errors
  • does not improve logic
  • does not optimize how the code runs

Summary

Prettier is an autopilot for the code's visual structure. It makes the code clean, consistent, and predictable, so it is easier to read and maintain.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.