HTML Formatter
Paste messy markup, get cleanly indented HTML — with pre/textarea/script/style content preserved exactly.
Privacy: formatting runs entirely in your browser — your markup never leaves this page.
How to use
- Paste your HTML into the input.
- Pick an indent width (2 or 4 spaces) and read the formatted output.
- Copy the result — pre and script blocks stay exactly as authored.
Frequently asked questions
What does the formatter change and what does it keep?
It re-indents tags and collapses runs of whitespace between them, but leaves the content of pre, textarea, script and style elements byte-for-byte untouched — so a code sample inside pre keeps its exact line breaks, and inline scripts are not rewritten.
My HTML is malformed — will it fail?
No. The tokenizer is deliberately forgiving: unclosed tags get closed by indentation recovery, stray closing tags are tolerated, and attributes containing > characters are handled. You always get output; it just may not fix underlying structural mistakes.
Why does my text run together after formatting?
Whitespace between block-level tags is collapsed, so incidental line breaks in your source disappear — that is the cleanup. If you need the spacing preserved, wrap that region in a pre element and format again.
Does the formatting change how the page renders?
Rendering is unaffected except for the whitespace collapsing mentioned above: HTML collapses whitespace anyway outside pre/textarea. No attributes, elements or text content are added or removed.
Is my HTML uploaded anywhere?
No — parsing and re-indenting happen entirely in your browser. Paste proprietary templates with confidence.