HTML Formatter
Indent tangled HTML into a readable structure, or strip it down for production.
How to use the HTML Formatter
- 1Paste your HTML.
- 2Press Format to indent it, or Minify to compress it.
- 3Set your preferred indentation width.
- 4Copy the result or download it.
How it works
The formatter tokenises the markup into tags, text, comments and doctype declarations, then re-emits it with indentation tracking the nesting depth. Void elements such as img, br and input do not increase the depth, since they never close.
Some content must not be touched. Text inside pre and textarea is whitespace-significant — reindenting it changes what the page displays. Script and style blocks contain other languages entirely, where reindentation could break a template literal or a string. All four are passed through verbatim.
Minifying collapses whitespace between tags, removes comments and drops trailing spaces, while applying the same protections. It is a safe structural minify rather than an aggressive one: attribute quotes and optional closing tags are left alone, because removing them is where minifiers break pages.
The markup is only ever handled as text. It is never inserted into this page, so pasting hostile HTML here cannot execute anything.
Everything runs in this page. Nothing you paste is transmitted, logged or stored, which is what makes it safe to drop a production payload in here while you are debugging.