Skip to main content
WizTools123
Free Online Tools

Tool Categories


Text Tools New Tool

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.

Free Forever Nothing Uploaded Real Tab Stops Safe for Code
Free Online Tabs to Spaces and Spaces to Tabs Converter
Share this tool
Tabs and Spaces Everything happens in this tab. Nothing you paste is sent anywhere.
Your text
0 characters 0 words 0 lines
Converted
0 characters 0 lines
Direction
What to change

0 lines 0 tabs in 0 leading spaces in 0 lines changed

0 lines started with both tabs and spaces. That is the indentation that looks right in one editor and wrong in the next.

Buy Us A Coffee

Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.

Buy Us A Coffee

How to Use Tabs and Spaces Converter

Step by step, start to finish.

1
Paste the code or text

Drop a file on the box if it is long. Nothing is uploaded, so unreleased code is safe here.

2
Choose the direction and width

Tabs to spaces or spaces to tabs, and the width your project uses. Two for JavaScript and Ruby, four for most things, eight for Go and old C.

3
Decide how much to touch

Leave "only the indentation" on for code and for data in columns. Turn it off only when you really want every tab in the line converted.

4
Check the mixed line count

If lines mixed tabs and spaces, the note says how many. Those are the lines that look fine in your editor and wrong in everyone else's.

Key Features

What this tool does, and what it does not do.

Real tab stops

Tabs expand to the next stop and spaces collapse back at the stop, the way editors and terminals actually behave.

Both directions

One tool, one switch. No hunting for the opposite page when the project changes its mind.

Indentation only

The default touches the start of the line and nothing else, so tab separated data survives.

Mixed lines reported

Lines that started with both tabs and spaces are counted, which is usually the bug you came here for.

Trailing whitespace

An optional pass that removes the spaces at the end of lines, the ones that show up in every diff.

Nothing uploaded

Source code goes in and stays in your browser. There is no server in the middle to receive it.

About 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 exact. Swapping every tab for a fixed number of spaces is only right for a tab at the start of a line; a tab in the middle of a line jumps to the next tab stop, and this converter follows those stops so text stays in its column.

The second thing it protects is data. A great deal of text is tab separated, and a line of it can look like an indented line. Converting the tabs inside it would merge the columns into ordinary spaces, so by default this page only touches the whitespace at the start of a line and leaves tab separated values intact.

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

Common questions about this tool.

The one your project already uses. Two is common in JavaScript, TypeScript and Ruby; four in Python, PHP and C#; eight in Go and in older C code. If you are converting to tabs, the width decides how many spaces make one tab, so picking the wrong one changes the depth of the indentation.

Because the indentation was not a whole number of steps. Six spaces at a width of four is one tab and two spaces. Those two spaces are kept, otherwise the line would move two columns left and the alignment would change.

Your columns stay intact with the default, which converts only the indentation at the start of each line. Switching that off converts every tab in the line, which suits prose and aligned comments. Keep it on for any text that has data columns separated by tabs.

The result uses plain line feeds. Carriage returns from Windows or old Mac files are read correctly and not carried through, which is what nearly every tool expects today.

It makes indentation consistent in the way that causes most trouble: all tabs or all spaces, at the width you choose, with mixed lines counted first. How deep a block should be nested is a decision about the code itself, and your editor's formatter is the place for that.

More Text Tools

Other tools from the same hub, free and in your browser.

All Text Tools

Feedback

No feedback on this tool yet. Yours would be the first.