Tab to Space Converter
Convert tabs to spaces and spaces to tabs online. Choose 2, 4, or 8 spaces per tab. Free indentation converter for code and text.
Three steps to get started
Choose direction
Select "Tabs → Spaces" or "Spaces → Tabs" to set the conversion direction.
Set spaces per tab
Choose 2, 4, or 8 spaces per tab to match your project's coding style.
Paste and copy
Paste your code into the input field and copy the converted output instantly.
Why indentation consistency matters
Code indentation is more than aesthetic — it determines program structure in whitespace-sensitive languages like Python and YAML, and affects readability in every language. The endless tabs-vs-spaces debate exists because different editors render tabs at different widths (2, 4, or 8 columns), causing indentation to look different depending on who opens the file.
Converting to spaces eliminates ambiguity: every editor shows exactly the same visual indentation. Converting to tabs reduces file size (one byte vs. 2–8 bytes) and lets each developer configure their preferred visual width locally.
Common use cases
- Pasting code from Stack Overflow — copied code often mixes tabs and spaces
- Migrating between editors — VS Code defaults to spaces, Vim often inserts tabs
- Pre-commit formatting — normalize indentation before running Prettier or Black
- YAML/JSON editing — these formats require spaces, not tabs
This tool processes your text entirely in your browser. No code or data is ever sent to a server. Paste any amount of text and get instant results.