Tabs vs Spaces
Side-by-side comparison, when-to-use-each guide, and instant conversion. Reviewed for 2026.
Go (official). Makefiles (required). 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 are more common overall, though surveys show a fairly even split among developers and it varies by language. Spaces dominate in Python, JavaScript, Ruby, C# and PHP; tabs dominate in Go. 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.
Frequently asked questions
Which actually wins by usage?
Spaces are more common overall, though surveys show a fairly even split among developers and it varies by language. Spaces dominate in Python, JavaScript, Ruby, C# and PHP; tabs dominate in Go. 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.