Tabs vs Spaces

The tabs-versus-spaces debate is a programming rite of passage. Tabs are single characters whose display width each developer can configure, so everyone reads code at their preferred indentation size. Spaces are fixed — indentation looks identical everywhere but takes multiple characters per level.

Beyond tribal loyalty, there are real considerations: accessibility, alignment, file size, and tooling defaults. Both work; what matters is that a codebase picks one and enforces it, ideally via a formatter so nobody has to think about it.

At a glance

AspectTabsSpaces
CharacterOne tab per indent levelMultiple spaces per level
Display widthConfigurable per developerFixed for everyone
AccessibilityScreen readers can adapt widthFixed width
AlignmentCan misalign mid-lineConsistent alignment
Common inGo, MakefilesPython (PEP 8), JS style guides

When to use Tabs

  • You want each developer to set their own indent width.
  • You're working in Go or Makefiles that require tabs.
  • You value smaller files and adjustable accessibility.

When to use Spaces

  • You want indentation to look identical everywhere.
  • You follow guides like PEP 8 or Prettier defaults.
  • You need consistent alignment across editors and tools.

Verdict

Neither is objectively correct — the winning move is to standardize and automate. Many popular style guides and formatters default to spaces, and some languages (Makefiles, Go) mandate tabs. Pick one, encode it in an editorconfig and formatter, and stop debating. When you inherit code using the other style, convert it in one pass so the whole file stays consistent.

Frequently asked questions

Related free tools