Tabs vs Spaces
Side-by-side comparison, when-to-use-each guide, and instant conversion. Reviewed for 2026.
Go (official). Makefiles (required). YAML deeply nested. Accessibility (configurable width helps low-vision developers).
Python (PEP 8 recommends 4 spaces). JavaScript (most style guides: 2 spaces). Ruby (2 spaces). Markdown lists in many parsers.
| Aspect | Tabs | Spaces |
|---|---|---|
| Python PEP 8 | Discouraged | 4 spaces |
| Google JS style | No | 2 spaces |
| Go fmt | Tabs | No |
| Makefiles | Required | Will fail |
| Accessibility | Configurable for low-vision | Fixed width |
Frequently asked
Which actually wins by usage?
Spaces, by a wide margin. The 2017 Stack Overflow survey found 38% used tabs vs 42% spaces. A 2020 GitHub analysis of 400k+ repos found spaces dominant in Python, JavaScript, Ruby, C#, PHP. Tabs dominant in Go, Lua. Mixed in C/C++.
Why does Go use tabs?
Go's authors (Rob Pike, Ken Thompson, Robert Griesemer) prioritised one-true-format and developer choice. Tabs let each developer view code at their preferred width while keeping the file identical.