Free text & code formatter

Text Indentation Formatter

Fix messy, mixed-up indentation in one pass. Normalize every line to tabs or spaces, trim trailing whitespace, and collapse extra blank lines—with live before and after stats.

Before

0 chars

After

0 chars
Paste text to see reindent stats.

Consistent indentation, automatically

Auto-detects indent depth

Reads each line's leading whitespace, converts tabs to columns, and infers the indent level even when spacing is inconsistent.

Tabs or spaces, your choice

Re-emit every line using tabs or a configurable 1-8 space width, matching your project's style guide.

Cleans up the rest too

Optionally trim trailing whitespace and collapse runs of 3 or more blank lines in the same pass.

How to use the indentation formatter

  1. Paste your textDrop in code or structured text with inconsistent tabs and spaces.
  2. Choose your settingsPick tabs or spaces, set the space width, and toggle the cleanup options.
  3. Copy or downloadGrab the reformatted result from the After pane, or save it as a .txt file.

Why indentation consistency matters

Mixed indentation is one of the most common sources of quiet bugs and messy diffs. When some lines use tabs and others use two, three or four spaces, editors render the same logical depth differently depending on tab-width settings, which makes nested blocks hard to scan and can even change behavior in whitespace-sensitive languages. Version control makes the problem worse: a single reformat can turn a one-line change into a hundred-line diff, burying the actual edit under noise and making code review far harder than it needs to be. This formatter solves the root cause rather than papering over it. Instead of blindly replacing tabs with spaces or vice versa, it measures each line's true indentation depth in columns, accounting for how tabs expand, and then re-emits every line at a consistent level using the unit you choose. Combined with trailing-whitespace trimming and blank-line collapsing, a single pass turns a document that has been edited by multiple people, tools or editors back into something clean, predictable and easy to diff.

Cleaner diffs

Consistent indentation means future edits show up as the actual change, not a whitespace reflow.

Editor-independent

Fixed indentation renders the same regardless of a teammate's tab-width setting.

Safer for code

Only leading and trailing whitespace is touched; the meaningful content of every line is preserved exactly.

Text indentation formatter FAQ

How does the indentation formatter detect indent depth?

It reads each line's leading whitespace, converts tabs to columns, auto-detects the smallest common space unit used in your text, and rounds the result to the nearest indent level so mismatched tabs and spaces line up consistently.

Will this reformat my code safely?

The tool only rewrites leading whitespace and optional trailing whitespace or blank lines. It never touches the visible content of a line, so code logic and text stay intact.

Can I choose spaces instead of tabs?

Yes. Pick Spaces as the indent unit and set how many spaces represent one indent level, from 1 to 8, and every line is re-emitted using that unit.

What does collapsing blank lines do?

When enabled, any run of three or more consecutive blank lines is reduced to a single blank line, tidying up excess vertical whitespace without removing intentional single blank-line breaks.

Is this indentation formatter free and private?

Yes. It runs entirely in your browser with no account or upload required, so your text and code never leave your device.

Try other text tools