I Will Die on the Hill of 2-Space Indents

by Justin Henry, Founder / Principal Engineer

Look, we've solved web performance, bundle size, accessibility, and developer experience. The only real problem left in modern web dev is: should your code be indented with 2 spaces or 4?

I'm here to say what needs to be said: 2-space indents are objectively correct, morally superior, and anyone who disagrees is either wrong or using Go.

Is this important? Absolutely not. Will I write 500 words about it anyway? Tragically, yes.

The Web Is Narrow, Your Indents Should Be Too

More often than not, modern web dev looks like a 13" laptop, three side-by-side editor panes, and a chat window lurking nearby, waiting to ruin your flow. Why would you waste precious horizontal real estate on 4 spaces per level of nesting?

With 4 spaces:

  • Your React component gets to level 4 and suddenly you're in line-wrap hell
  • Tailwind class lists look like a staircase
  • if inside map inside Promise.all inside try/catch becomes modern hieroglyphics

With 2 spaces:

  • You can actually read JSX without side scrolling
  • Nested objects don't look like you copy-pasted Python examples
  • Your brain accepts "yeah this is bad, but at least it's compact"

This is not about readability. It's about pretending you are in control of the chaos.

"But 4 Spaces Are More Readable" 😩

So is writing fewer nested blocks, but here we are.

The 4-space argument usually goes: "It's easier to visually distinguish nesting levels." My brother in Christ, if you need geological strata of whitespace to understand your control flow, the problem is not the spaces.

Also: we invented syntax highlighting, code folding, minimaps, and ctrl+click navigation, and you're telling me the thing that truly saves you is two extra spaces per level?

Tab People, I See You

Then there are the "just use tabs so everyone can choose" folks. In theory: beautiful. In practice:

  • Someone's editor is misconfigured
  • Someone's .editorconfig is missing
  • Someone on the team uses a web-based editor that treats tabs like a suggestion
  • Git diff turns into a performance art piece about whitespace conflicts

And now your PR review is half "why did this line change" and half staring into the abyss of mixed indentation.

I respect the idealism. I do not respect what it does to git blame.

2 Spaces: The Framework of Indentation

You know who uses 2 spaces by default?

  • Most JS/TS style guides
  • Prettier (aka the style police)
  • Basically every UI framework starter template you've touched in the last five years

At this point, 2 spaces isn't a preference; it's vendor lock-in. Your linter, formatter, and the three boilerplates you copy-pasted all silently agreed on 2 spaces a long time ago. You can fight it, but only in the same way you can "fight" time zones or CSS.

You're not principled. You're just tired.

None of This Matters (But Also It Absolutely Does)

Objectively, indentation size does not make your app faster, your UX better, or improve any metric that your PM cares about.

But subjectively, it:

  • Determines whether you feel mild joy or low-level disgust every time you open a file
  • Influences how bloated your code feels
  • Gives you a petty hill to die on in code review, which is sometimes all that keeps us going

So yeah, on paper, this is a meaningless debate. In practice, we've automated everything else and this is one of the last remaining places to have an opinion.

The Takeaway (There Doesn't Need To Be One)

Here's my sincere recommendation: Use 2 spaces, let Prettier enforce it, and pretend it was a deeply considered architectural decision.

And if your team insists on using 4 spaces? That's fine. You can still ship great products, have a healthy culture, and write clean code.

You'll just be wrong.

More articles

AI in sports

Ben, under duress, shares advancements in the world of sport.

Read more

Generative tech is a lot more than LLMs

Matt got in a LinkedIn fight with a guy who had a bunch of followers and fake credentials, so he decided to take a big blog about it.

Read more

Tell us about your vision

Our office

  • Madison
    525 Junction Road St. 6500
    Madison, WI 53717