Tabs to spaces, plain and predictable
Tabs to spaces conversion replaces every tab character (\t, U+0009) in your text with a run of regular spaces. The run length comes from the Tab width control, which accepts integer values from 1 to 16 with a default of 4. So a tab with width 4 becomes four spaces; a tab with width 2 becomes two. The replacement is a flat character swap, not a column-aligned expansion: every tab gets the same number of spaces regardless of its position on the line.
That flat behaviour is what most code formatters expect. Editors that show tabs as variable-width whitespace render them differently from a fixed run of spaces, but on disk they are still single \t characters. Converting to spaces locks in the visual width and makes the file render identically across editors with different tab settings. If your build tooling complains about mixed indentation, this is the conversion to run before commit.
Other characters pass through untouched. Newlines stay as LF or CRLF, and the line ending shown in the input status bar is preserved. Non-tab whitespace (spaces, no-break spaces) is also untouched, so a line that already mixes tabs and spaces gets only the tabs expanded. For the inverse direction, see spaces to tabs.
How to use convert tabs to spaces
- 1Paste your tabbed text into the input panel on the left.
- 2Set the Tab width control to the number of spaces you want per tab.
- 3The expanded text appears in the output panel on the right as you type.
- 4Click Copy in the output header to copy the result.
- 5Click Download to save the result as a plain-text file.
Keyboard shortcuts
Drive TextResult without touching the mouse.
| Shortcut | Action |
|---|---|
| Ctrl F | Open the find & replace panel inside the input Plus |
| Ctrl Z | Undo the last input change |
| Ctrl Shift Z | Redo |
| Ctrl Shift Enter | Toggle fullscreen focus on the editor Plus |
| Esc | Close find & replace, or exit fullscreen |
| Ctrl K | Open the command palette to jump to any tool Plus |
| Ctrl S | Save current workflow draft Plus |
| Ctrl P | Run a saved workflow Plus |
What this tool actually does
Flat tab-to-space replacement
Every \t in the input is replaced with a run of tab_width space characters. The replacement is positional, not column-aligned: a tab three characters into a line still expands to the full configured width, not to the next column boundary. That matches most code formatters and avoids surprise with rendered indentation.
Tab width control, 1 to 16
The control accepts integer values from 1 to 16 with a default of 4. Values out of that range clamp back into it. Width 1 collapses every tab to a single space, which is useful for prose. Width 2 matches Ruby and JavaScript style guides; width 4 matches Python and most C-family code; width 8 matches the historical Unix terminal default.
Other characters untouched
Spaces, newlines, no-break spaces, punctuation, digits, letters and any other characters pass through verbatim. Only the tab character (U+0009) is replaced. A line that already mixes tabs and spaces gets only the tabs expanded, leaving any existing spaces in place.
Line endings preserved
LF stays LF, CRLF stays CRLF. The input status bar shows which line ending was detected so you can confirm the file format before copying. The replacement does not introduce or remove any newlines.
Runs entirely in your browser
No upload, no server-side processing, no log of what you pasted. The replace runs on every keystroke via a single regex pass. Long files of a few hundred kilobytes still convert in under a second on a desktop browser.
Worked example
Each tab expands to four spaces with the default width of 4. Other characters and newlines pass through.
name email role Alice [email protected] admin
name email role Alice [email protected] admin
Settings reference
| Setting or rule | Effect on output |
|---|---|
| Tab width (default 4) | Number of spaces written for each tab character. Accepts 1 to 16; out-of-range values clamp. |
| Replacement scope | Every \t in the input. Other characters untouched. |
| Replacement style | Flat: each tab emits the same number of spaces, regardless of column position. |
| Spaces in source | Pass through unchanged. A line with mixed tabs and spaces gets only the tabs expanded. |
| Newlines | LF stays LF, CRLF stays CRLF. |
| Empty input | Emits an empty string. |
FAQ
Does it expand tabs to a column position?
tab_width spaces, regardless of where the tab sits on the line. That matches the behaviour most code formatters expect. If you need column-aligned expansion, run the result through a downstream pretty-printer.What range can Tab width take?
What about lines that already mix tabs and spaces?
\t with width 4 becomes (four spaces from the tab plus the original two), which preserves the visual indent.