Convert tabs to spaces

Paste any text with tab characters and get the same text with each tab expanded to spaces. The tabs to spaces converter replaces every \t in the input with a run of space characters, with the run length set by the Tab width control. Other characters pass through untouched. The transform runs in your browser; nothing uploads.

Input
Line 1:1 LF cloud_done Saved locally
Result Tabs to Spaces
0 lines 0 chars

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

  1. 1Paste your tabbed text into the input panel on the left.
  2. 2Set the Tab width control to the number of spaces you want per tab.
  3. 3The expanded text appears in the output panel on the right as you type.
  4. 4Click Copy in the output header to copy the result.
  5. 5Click Download to save the result as a plain-text file.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun 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.

Input
name	email	role
Alice	[email protected]	admin
Output
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?
No. The replacement is flat: every tab becomes 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?
Integer values from 1 to 16. The default is 4. Values outside the range clamp back into it. Width 1 collapses every tab to a single space; 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.
What about lines that already mix tabs and spaces?
Only the tabs are replaced. Any existing space runs in the line stay exactly as they were. So a leading \t with width 4 becomes (four spaces from the tab plus the original two), which preserves the visual indent.
Is the text sent anywhere?
No. The replace runs entirely in your browser via JavaScript. Nothing is uploaded, nothing is logged, no record of your text exists on our servers.
How do I go the other way?
Paste your space-indented text into spaces to tabs. That tool replaces runs of spaces with tab characters, with a few different modes for which whitespace runs count as tab-equivalent.