Whitespace & Indent Normalizer

Paste any block of text — source code, Markdown, a log file, a CSV dump — and the tool rewrites its indentation, line endings, and trailing whitespace in one pass. Convert tabs to spaces (or back) at a chosen indent width, normalise LF / CRLF / CR, trim trailing whitespace, collapse blank-line runs, and strip the BOM. Live detection panel shows what was found before you commit. Pure client-side; nothing leaves your browser.

What was detected

Indentation
Indent width
Line endings
Trailing newline
BOM
Lines / chars

Options

Indentation
Line endings
Trailing whitespace
Blank-line collapse
Final newline
BOM

Output

 
How detection & rewriting work

The detection panel reads the input once and reports its indentation style (tabs, spaces, or mixed), the dominant indent width (when spaces), the line-ending mix (LF, CRLF, CR, or a combination), whether a leading BOM is present, and whether the file ends with a trailing newline. None of this rewrites anything yet.

Tab ↔ spaces rewrites only the leading whitespace of every line. Interior tab and space runs in the body of a line are never touched — they’re content, not indentation. When spaces → tabs is on, the leading space count is rounded down to the nearest tab-width multiple (so 6 spaces at a tab width of 4 becomes one tab plus two trailing spaces).

Line-ending rewrite splits the document on every \n, \r\n, or \r boundary and re-joins with the chosen separator. Mixed endings are normalised in the same pass — pick LF for Unix / macOS or CRLF for Windows, and bare CR lines become whichever you pick.

Trailing whitespace defaults to trimming trailing spaces only — Markdown’s two-space hard-break convention relies on trailing spaces, and tabs often indicate tab-indented code that should stay put. Turn on also trim trailing tabs if you want a complete wipe (useful before committing to a repo with a strict trailing-whitespace lint).

Blank-line collapse caps any run of 3+ consecutive empty lines at the value you choose. The default 0 removes every blank line; 1 keeps one (no double-spacing); 2 preserves paragraph breaks.

Final newline lets you pin the trailing newline state regardless of what the input has — ensure always adds one, remove always strips it, keep leaves it alone. The BOM toggle controls whether the leading U+FEFF (byte-order mark) is stripped before the rewrite.