Indent or minify markup, without touching what must not move.
What it's for
Make HTML or XML that is crammed onto one line readable again, with each tag on its own line and indented — or squeeze it small — and find a tag that was never closed.
Before you start
Have the markup to hand: the tagged code of a web page, an email template or a data file. It is formatted in your browser and nothing is sent anywhere.
Paste the markup
Replace the sample in Markup with your own HTML or XML. Markup is text built from tags in angle brackets, such as <p> and </p>.
Choose the indent
Indent sets how far each level is pushed in: Two spaces, Four spaces or Tab. Pick whatever the rest of your files use; two spaces is a common choice.
Or make it small instead
Tick Minify instead to remove the spacing between tags rather than add it, for a file that only a program will read. Indent is greyed out while it is ticked.
Format and copy
Press Format. The result is in the band at the top of the card — it also changes as you type — and Copy puts it on your clipboard.
Check for broken tags
If Structural problems appears below, each line names a tag and what is wrong with it. The output is still made, so you can look at its shape to find the spot.
Reading the result
If it goes wrong
It formats; it does not validate, and the page says so. Reporting "valid" because a document could be indented is telling you something the tool does not know.
Some elements have whitespace as content: pre, textarea, script and style. Re-indenting inside a pre destroys the code sample; a textarea gains leading spaces in its value. Those four are left untouched.
Void elements have no closing tag. Treat <br> as an opening one and everything after it indents one level deeper for ever — the most visible way a hand-written formatter fails.
And it does not parse to a tree. A tree round trip drops comments, CDATA and unusual doctypes. This is a token stream: everything that goes in comes out.
No, and it says so on the page. Validating means checking against the whole specification — entities, DTDs, namespaces, encoding declarations — and a tool that reports “valid” because it managed to indent a document has told you something it does not know. What it does report is the one class of fault it genuinely detects: a tag that never closes, and a closing tag that matches nothing.
Because whitespace inside it is content, not formatting. Re-indenting a pre block destroys the code sample it contains, and a textarea treated the same way gains leading spaces in its value. Script and style are left alone for the same reason. Those four elements are passed through exactly as they arrived.
Because they treat it as an opening tag. Void elements — br, img, input, hr, meta, link and the rest — have no closing tag in HTML, so nothing ever brings the indent back out, and the rest of the document drifts right for ever. It is the single most visible way a hand-written formatter fails, and this one knows the list.
No. It does not parse to a tree and re-emit, which is what drops anything the parser did not model — comments, processing instructions, CDATA, an unusual doctype. This works on a token stream: every token that goes in comes out, and only the whitespace between them changes. A formatter that silently deletes part of a document is far worse than one that leaves it oddly indented.
Because refusing is no use to somebody trying to see where it broke. The problems are listed and the formatted output is produced anyway, so you can look at the structure and find the missing tag. An unmatched closing tag is also deliberately not allowed to change the indent level — otherwise one mistake pulls every following line left and the whole document looks wrong.
No. Everything happens in your browser and nothing is transmitted or stored.
area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr have no closing tag. Nothing brings the indent back out once one is entered, so the whole rest of the document drifts right.
Important
Runs entirely in your browser. This formats rather than validates — well-formedness against the full specification is a larger claim than indenting supports. It reports the structural faults it genuinely detects and still produces output for a broken document. Nothing you type here is sent to our servers — the calculation runs entirely in your browser.