Indentation Fixer

Auto-indent code with spaces or tabs, with indentation style detection for consistency.

Indentation Fixer Runs locally · No sign-up
Fixed indentation

About Indentation Fixer

Copy-pasted code from emails, terminals, or other projects often arrives with mixed tabs and spaces, or no indentation at all, making the structure impossible to read. This tool re-indents your code with a consistent style so nesting is visible again.

It samples the input to detect whether the dominant style is tabs or spaces and suggests that convention, which you can override with any width. Indentation is rebuilt from braces and nesting depth, which covers most C-like languages; Python, which defines structure with indentation itself, is re-tabbed consistently but its logic cannot be auto-inferred.

Developers cleaning up pasted snippets before reviewing them, teams normalizing a shared codebase to one indentation style, and anyone comparing two versions of a file benefit from a uniform baseline. It is also a fast way to make a messy diff readable.

How to Use

  1. Paste code with inconsistent indentation.
  2. Choose spaces or tabs and the width.
  3. Copy the re-indented code.

Example

if (a) { console.log(1); } if (a) { console.log(1); }

Mixed tabs and inconsistent levels are normalized to a single, consistent indentation style.

FAQ

Can it detect the existing indentation style?

Yes, it samples the input and suggests the dominant style, which you can override.

Does it work on any language?

It re-indents based on braces and nesting, which covers most C-like languages; Python relies on indentation itself.

Will it change the code's behavior?

No for brace-based languages. Whitespace-only changes are purely cosmetic there.

Will it touch indentation inside strings?

No. Whitespace inside string literals and comments is left exactly as-is, because changing it there could alter text output or documentation.

Should I run it before committing code?

Yes. Normalizing indentation before a commit keeps diffs small and prevents whitespace-only changes from obscuring real edits, which makes the history far easier for reviewers to follow.