Tabs → Spaces
Replace every tab character with a configurable number of spaces. Default is 4.
spaces per tab
About Tabs → Spaces
This tool replaces every tab character (U+0009) with N spaces. Useful when migrating between codebases or editors that disagree on indentation, when producing output for a renderer that doesn't expand tabs, or when normalizing source before a diff.
When to use it
- Normalizing tab-indented code to space indentation
- Producing output for Markdown code fences (which require spaces, not tabs)
- Matching the indent convention of an existing project
- Cleaning a file mixed with tabs and spaces
How it works
The simple substitution /\t/g → ' '.repeat(N) replaces every tab with N spaces. Tab-stop alignment is not respected — every tab becomes exactly N spaces regardless of its column position.
Examples
foo bar (N=4)
foo
barFrequently asked questions
- Does it respect tab stops?
- No. Every tab becomes exactly N spaces. For tab-stop-aware expansion (where a tab fills to the next column boundary), use the expand(1) utility at the command line.
- What if the file is already space-indented?
- Files with no tabs pass through unchanged. The substitution is a no-op when there's nothing to replace.