Free Online Tabs to Spaces and Spaces to Tabs Converter
Change the indentation of code or text both ways. Tabs become spaces using real tab stops rather than a flat multiply, spaces become tabs at the width you set, and only the indentation is touched unless you ask for the whole line. Mixed indentation is reported.
Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.
A Tab Is a Stop, Not Four Spaces
Which is why replacing every tab with four spaces moves your columns.
A tab character does not mean "insert this many spaces". It means "move to the next tab stop". With a width of four the stops are at columns 4, 8, 12 and so on, so a tab at the start of a line is worth four spaces, but a tab after two characters is worth only two. Tools that multiply instead of stepping get the first case right and every other case wrong, which is how a neat table turns into a ragged one.
| Line | Flat multiply by 4 | Real tab stops at 4 |
|---|---|---|
| [tab]name | 4 spaces, then name | 4 spaces, then name. Same answer. |
| ab[tab]name | ab, 4 spaces, name. Column 6. | ab, 2 spaces, name. Column 4, where the stop is. |
| abcd[tab]name | abcd, 4 spaces, name. Column 8. | abcd, 4 spaces, name. Column 8. Same again. |
How to Convert Tabs and Spaces
A few steps, and nothing is uploaded.
What to Know About Tabs and Spaces
Including why four spaces per tab is not always right.
Key Features & Capabilities
What this tool does, and what it deliberately does not.
About the Tabs and Spaces Converter
Tabs against spaces is an old argument, and this page takes no side in it. What it does is make moving between the two safe, because the obvious way of doing it is wrong often enough to cause real damage. Replacing every tab with a fixed number of spaces is correct only when the tab is at the start of the line; everywhere else it moves the text to the wrong column.
The second common accident is bigger. A great deal of data is tab separated, and a line of it looks like an indented line to a careless converter. Turning those tabs into spaces loses the column boundaries permanently, because a run of spaces cannot be told apart from a space inside a value. For that reason the default here only ever touches the whitespace at the start of a line.
The count of mixed lines is the part that earns its keep. Indentation that mixes tabs and spaces renders differently in every editor, so the file looks neat to the person who wrote it and broken to everyone else. Seeing that eleven lines are mixed, before converting anything, usually explains the argument the team has been having about the file.
Frequently Asked Questions
Tab width, mixed indentation, data in columns and alignment.