Convert between tab indentation and space indentation in code or text. Configurable tab width (2, 4, 8 spaces). The reverse direction (spaces → tabs) preserves alignment correctly by converting only leading spaces.
How to use the Tab ↔ Space Converter (Configurable Width)
Paste code or text, choose a direction — tabs to spaces, or spaces to tabs — and set the tab width. The output converts indentation at that width; copy the result when it looks right.
Converting between tabs and spaces
Indentation style is a perennial source of friction. Some projects mandate spaces, others tabs; a file that mixes the two renders unpredictably across editors and outright breaks whitespace-sensitive formats like Python, YAML, and Makefiles. Reindenting by hand is slow and easy to get wrong.
This converts the indentation of every line — tabs to a fixed number of spaces, or runs of leading spaces back to tabs — at the width you set. To also strip trailing whitespace and blank lines, use the whitespace trimmer; to switch line-ending style, the line ending converter.
Common use cases
Style conformance — convert a file to your project’s spaces-or-tabs rule.
Fixing mixed indentation — normalize a file that contains both.
Makefile rescue — Makefiles require real tabs; convert spaces back to them.
Paste cleanup — repair indentation mangled by a web form or chat client.
Diff stability — settle on one indent style to avoid whitespace-only diffs.
Frequently asked questions
What tab width should I use?
Match your project. Two and four spaces are the most common; eight is the terminal default.
Can it convert spaces back to tabs?
Yes. The spaces→tabs direction converts only the leading spaces on each line, so alignment inside the line is left intact.
Will this fix a file that mixes tabs and spaces?
Yes. Converting everything to one style is exactly what resolves the inconsistency that breaks Python and YAML.