Tab / Spaces Converter
Convert between tabs and spaces in both directions with 2/4/8 width options — fix messy indentation from copied code in one click.
>_ USAGE GUIDE
Paste code or text whose indentation mixes tabs and spaces, choose the direction (Tab → Spaces or Spaces → Tab) and the width (2 / 4 / 8), and the whole block is normalized in one click — then copy it straight back into your editor.
The classic trigger is copying code from someone else's repo or a web page: the pasted block shows tabs in some lines and spaces in others, Python then raises an IndentationError, or the alignment shifts between editors. Normalizing indentation here makes the paste clean again.
- Paste the code: mixed-indentation text you need to clean up
- Pick a direction: Tab → Spaces to conform to space-indented projects; Spaces → Tab for tab-based repos
- Choose the width: 2 / 4 / 8 so visual indentation is preserved and nesting is not destroyed
- Copy back: grab the normalized output and paste it into your editor
The tool rewrites only the indentation characters and leaves the rest of the code untouched; all processing happens locally with zero uploads.
>_ FAQ
Q1 · Are tabs or spaces better? Why is this controversial?
This is a classic developer debate. Tabs let each reader choose their own display width and produce smaller files; spaces render identically everywhere and never shift because of editor settings. Most languages settle on one (Python's official guidance is 4 spaces, Go uses tabs, Rust defaults to 4 spaces). The real rule is not which one you pick but being consistent project-wide — mixing them is what breaks things.
Q2 · Code I copied from the web looks misaligned. How do I fix it?
Copying from a page often quietly converts tabs to spaces or vice versa, scrambling the indentation levels. Drop the pasted result into this tool, normalize it to one style (spaces or tabs per your project, at the right width), and paste it back. If your project has no stated rule, converting to spaces is the safest, most compatible default.
Q3 · Will converting change my code's logic or the content of strings?
No. The tool replaces only the tabs and spaces used as indentation. A real risk would be disturbing tab characters inside string literals, but conversion focuses on leading indentation and does not rewrite string contents. That said, run your project's tests or review the git diff afterward to confirm nothing unexpected changed.
Q4 · Which width — 2, 4, or 8 — should I use?
The width decides how many spaces a tab expands to (or collapses from). Choosing it wrong does not lose information, but it makes nesting look tighter or looser. Most projects use 4 spaces (backend-heavy) or 2 (common in front-end), so follow the existing style. When unsure, convert to 4 spaces, the most common default.
Q5 · Why do tabs and spaces appear misaligned when they coexist in one file?
Because editors disagree on how wide a tab is (some treat it as 2, others as 4 or 8). When tabs and spaces coexist, the file aligns differently in different editors and looks structurally broken. The fix is to normalize the entire file to a single indentation style — done here in one click — after which it looks identical no matter who opens it.