Skip to content
TextArray
100% local

HTML formatter

Pretty-print HTML with proper nesting indentation, without ever touching pre, script or style content.

Input
Output

HTML formatter

Paste minified, copied or just messy HTML and get it back properly indented: every nested element steps in by your chosen indent (two spaces, four spaces or tabs), void elements such as br, img, input, meta and link are treated as non-nesting, and inline elements like a, b, em, strong, span and code stay on their parent's line whenever the whole element fits — so short list items and links stay compact instead of exploding into three lines each.

The formatter is deliberately forgiving, because HTML in the wild is malformed. Mismatched or unclosed tags never produce an error: a stray closing tag is dropped, an unclosed element is closed implicitly by its parent, and the rest of the document formats as best it can. The content of pre, script and style elements passes through verbatim — your preformatted text keeps its spacing and your embedded JavaScript and CSS are never re-indented or reflowed.

Two cleanup options handle the usual noise. "Remove blank lines between elements" strips the empty lines that pile up when markup is copied from templates, and "Collapse whitespace in text" turns runs of spaces and line breaks inside text nodes into single spaces — never inside pre, script or style. The tally under the output reports elements, lines in and out, and the deepest nesting level.

Everything runs locally in your browser: pages, templates and email markup never leave your machine. Copy the result or download it as a .txt file.

FAQ

What happens with malformed HTML?
It formats anyway. A stray closing tag is dropped, an unclosed element is implicitly closed by its parent, and no error is ever shown — real-world HTML is rarely perfect and the formatter is built for that.
Will my script, style or pre content be changed?
No. The inner content of pre, script and style elements passes through byte for byte. Preformatted spacing, embedded JavaScript and CSS keep their exact original layout.
When do inline elements stay on one line?
Inline elements (a, b, i, em, strong, span, code, small, sub, sup) stay on their parent’s line when the whole element fits within about 80 characters at the current indent. Longer elements break into indented lines like any block element.
What does "Collapse whitespace in text" do?
Runs of spaces, tabs and line breaks inside text nodes become a single space, which is how browsers render them anyway. Content inside pre, script and style is never collapsed.
Is my HTML uploaded anywhere?
No. The tool runs entirely in your browser and your markup never leaves your device.