My Tool Studio
Text

Tabs to Spaces

One teammate's editor indents with tabs, yours uses spaces, and the diff flags every line even though nothing really changed. Paste the file here to convert tabs to spaces online at whatever width your project standardized on, anywhere from 1 to 8 spaces per tab, with 2 as the default. One click will replace tabs with spaces through the entire paste, and a second button runs the conversion backward when a style guide demands hard tabs instead. Everything happens in your browser, so proprietary source code never leaves your machine.

Always freeNo sign upRuns in your browser

How to use

01

Choose the tab width

Set the Tab size field to the number of spaces one tab should equal, anywhere from 1 to 8. Match your project: 2 is common for JavaScript, 4 for Python.

02

Pick a direction

Click Tabs to Spaces to expand tabs, or Spaces to Tabs to compress runs of spaces back into tabs. The active direction shows as the highlighted button.

03

Convert and copy

Paste your code or TSV data into the Input pane. The converted version appears on the right immediately, and the Copy button carries it back to your editor.

Why Tabs to Spaces

Common questions

Does the conversion touch tabs in the middle of a line?
Yes, every tab in the text is replaced, not just the leading indentation. That matters for tabs inside string literals and for TSV fields, so diff the result before committing code.
Can I make a TSV file readable by expanding its tabs?
Partially. Each tab becomes a fixed run of spaces, so columns only line up when the values are similar lengths. It's good enough for a quick look inside a data file, but it isn't true column alignment.
How does Spaces to Tabs decide which spaces become tabs?
It replaces every run of exactly the Tab size number of consecutive spaces, anywhere in the text. Spaces inside strings or comments can get converted along with indentation, so review the output before shipping it.
What width should I pick when I replace tabs with spaces in Python?
Four, which is what PEP 8 prescribes. The width itself matters less than consistency, since Python only objects when tabs and spaces are mixed unevenly within the same block.
Will converting a Makefile's tabs break it?
Yes. Make requires recipe lines to start with a literal tab character, and a spaces version fails with a missing separator error. Keep Makefiles out of this converter entirely.
Is mixing tabs and spaces really a problem in shared code?
It is. Python 3 refuses to run inconsistently indented files, diffs fill with whitespace noise that hides real changes, and the same file renders with different indent depths in every editor. Converging on one style removes all three headaches.
Does the converter change anything besides whitespace?
No. Letters, symbols, and line breaks pass through untouched, and only the tab and space substitution you asked for is applied. What comes out is your text with different indentation characters, nothing more.

More Text tools

View all