TextArray
100% local

Tabs to spaces

Convert tabs to spaces or pack spaces back into tabs, at any tab width.

Input
Output

Tabs to spaces

Tabs or spaces is the oldest argument in programming, and the answer usually depends on whose file you have open. This tool settles it for a given block of text: paste code, a config file, a Makefile or a column of exported data, pick a direction, and the whitespace is rewritten to match.

Converting tabs to spaces expands each tab the way an editor does — a tab advances the cursor to the next tab stop rather than blindly inserting a fixed number of spaces, so the character after it lands in the same column it did before. Choose 2, 4 or 8 spaces per tab, or set a custom width between 1 and 16. Going the other way, spaces to tabs packs runs of blanks back into tabs wherever a tab reaches the same column, and leaves any leftover spaces in place so nothing shifts.

Indentation only restricts the conversion to the leading whitespace of each line, which is what you want for source code: indentation gets normalised while tabs inside strings, comments or aligned TSV columns are left alone. Turn it off to rewrite every tab and every run of blanks in the text. Windows (CRLF), Unix (LF) and classic Mac (CR) input all work, and the output always uses LF. The tally under the output shows how many tabs went in, how many came out and how many lines changed, so a mistaken width is obvious immediately.

Everything happens in your browser. Your code is never uploaded, so proprietary source, internal configuration and client data are all safe to paste. Copy the result, download it as a .txt file, or send it back to the input for another pass.

FAQ

How many spaces should one tab be?
Four is the common default and the width most style guides pick. Web projects often use 2, classic Unix tooling assumes 8. Set whatever your formatter expects — any width from 1 to 16 works.
Will this break my Makefile?
It will if you convert the recipe lines: make requires a real tab there and rejects spaces. Convert Makefiles in the spaces-to-tabs direction, or not at all.
Does one tab always become the same number of spaces?
No. A tab advances to the next tab stop, so at a width of 4 a tab in column 3 becomes a single space, not four. That is how editors render tabs, and it keeps your columns aligned.
What does "Indentation only" change?
It limits the conversion to the whitespace at the start of each line. Tabs and spaces inside the line — in strings, comments or aligned columns — stay exactly as they are.
Is my text uploaded anywhere?
No. The tool runs entirely in your browser and your code never leaves your device.