ARZENTIQ
DEVELOPER & DATA

Indentation Converter (Tabs ↔ Spaces)

Convert code indentation between tabs and 2, 4 or 8 spaces — source unit detected or set by you — touching only leading whitespace, with optional trailing trim.

The same code re-indented to your project’s style, with the detected source unit, the number of lines changed and any mixed tab-and-space lines called out.

Example: A function indented with 4 spaces (depth 3) is detected as 4 per level and rewritten with 2 spaces, or with one tab per level; a line with trailing spaces is trimmed and counted.

v0.1.0 · last reviewed 19 September 2026
Loading the workspace…
BUILT TO BE UNDERSTOOD

Only the
left margin.

How the source unit is detected, how levels are counted, and what is never changed.

Detecting the unit

Each non-blank line's leading whitespace is inspected. If more lines start with tabs than spaces, the source unit is tabs. Otherwise the differences in space count between consecutive indented lines are tallied and the most common difference is the unit — 2 beats 4 on a tie, since 4-space code also shows 2-space steps rarely but 2-space code never shows 4-space steps consistently. The detected width is reported; override it if the file is unusual.

Converting

The leading whitespace of each line is measured in columns — a tab advances to the next multiple of the source width — and divided by the source width to give the level. The line is rewritten with the target unit repeated that many times; any remainder columns (alignment that was not a whole level) are kept as spaces so continuation lines stay aligned. Everything after the indentation, including tabs and spaces inside strings or comments, is untouched. Trailing whitespace can be trimmed and is counted.

Limits

The converter has no idea what language it is reading. Languages where indentation is syntax (Python, YAML, Makefiles — which require tabs) convert correctly as long as the source was consistently indented; mixed tab-and-space lines are flagged because their intended depth is a guess. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.

SOURCES

  • Leading-whitespace arithmetic only (columns ÷ source width = levels; a tab advances to the next tab stop). No language parsing

Last reviewed 19 September 2026. How results are checked: How we verify.