HTML Formatter
Make unreadable HTML readable again. Paste a minified page or a fragment that has drifted out of shape, choose your indentation, and get it back properly nested. Inline elements are kept on the line they belong to, because breaking them would change how the page renders.
Developer Tools
Private by default
This tool runs entirely in your browser. Your data is never uploaded to a server.
How it works
What the formatter touches
Only whitespace between tags. Each nested level gains one indent, attributes stay on their element unless a wrap length forces them apart, and the content of pre, textarea, and script blocks is left byte-for-byte as it was.
- Whitespace between inline elements is rendered as a space, so those are not broken onto separate lines.
- Content inside pre and textarea is preserved exactly — breaking it would change what the user sees.
- Void elements (img, br, input, meta, link) take no closing tag and no extra indent level.
- Consecutive blank lines are collapsed to at most two, so deliberate spacing survives without the file doubling in height.
For reference
Which elements are treated as inline
| Category | Elements | Line handling |
|---|---|---|
| Text-level | a, span, strong, em, code, small | Kept on one line |
| Replaced inline | img, br, input, button, select | Kept on one line |
| Block | div, p, section, article, header | Own line, indented |
| Lists | ul, ol, li, dl, dt, dd | Own line, indented |
| Preserved | pre, textarea, script, style | Contents untouched |
The distinction is about HTML's own whitespace rules, not about the CSS display property you may have applied.
How to use
4 clear steps.
Paste the HTML into the input.
Choose spaces or tabs and how wide the indent should be.
Optionally set a line length to wrap long attribute lists.
Copy the formatted output.
Good to know
Frequently asked questions
- Does formatting change how the page renders?
- Not for block elements. Inline elements are the exception: whitespace between them is meaningful, so a break inserted between two spans would add a visible space. The formatter keeps inline content on one line to avoid exactly that.
- Will it close my unclosed tags?
- No. It re-indents what you give it and leaves the structure alone. Void elements like img and br are handled correctly, but a genuinely unbalanced document stays unbalanced — with the indentation now making that obvious.
- Can it minify HTML too?
- No, and deliberately so. Safely stripping HTML whitespace requires knowing which elements treat it as significant, including anything inside pre or with white-space set in CSS. That belongs in a build step, not a paste box.