Re-indent HTML with a real tokenizer. Nested elements are laid out, inline content flows, and pre, script and style blocks are reproduced exactly as written.
Waiting for markup
Paste a page or a fragment. Script and style bodies are reproduced exactly as written.
Formatted markup appears here
Nested elements are indented, inline content flows, and whitespace-sensitive elements are left alone.
HTML Formatter runs entirely on your device — nothing is uploaded.
You’re on the Free plan. Compare plans
HTML that has been through a build step, a CMS, or a colleague's editor arrives in whatever shape it arrives in. A formatter puts the structure back: one element per line where that helps, nested content indented, and inline content left flowing so a paragraph still reads as a paragraph.
The reason this is harder than it sounds is that a regular expression cannot read HTML. Inside a <script>, the characters if (a < b) are not an open tag, and a formatter that thinks they are will destroy the script. <img> has no closing tag and never did, so treating one as an opening tag leaves everything after it nested a level too deep. This tool reads the document with a tokenizer that knows about raw-text elements, void elements and escapable raw text, then builds a tree and prints it.
Three things come back byte for byte. The contents of <pre> and <textarea>, where every space and newline is significant and changing one changes the page. And the bodies of <script> and <style>, which are moved to a new indentation as a block but never restructured — reformatting JavaScript or CSS correctly needs a parser for those languages, and this tool does not pretend to have one.
The rule that separates a careful formatter from a careless one is what happens between inline elements. A space between </b> and <i> is a real space in the rendered output; no space between them means the words run together. So a single space survives wherever the source had any whitespace, and none is ever introduced where the source had none. Line wrapping only happens at a space that already existed, for the same reason.
Formatting is idempotent: running the output through again gives the same result, so this will not fight with a formatter in your editor or produce a different answer the second time.
No. A script or style block is moved to the correct indentation as a whole, but its contents are reproduced exactly as written. Formatting those languages properly needs a parser for each of them, and guessing is how working code gets broken.
Nothing at all. Every space and newline inside pre and textarea is significant — it is what those elements are for — so they are reproduced byte for byte, including their original indentation.
Neither. Where the source had whitespace between two inline elements, one space survives; where it had none, none appears. That space is visible on the page, so changing it would change how the text reads.
No, and it does not try. A close tag with nothing open stays in the output rather than being quietly deleted, and unclosed elements are laid out as written. Use the HTML Inspector to find out what is wrong; this tool only changes whitespace.
Yes. Formatting already-formatted output returns the same text, so it will not oscillate with another formatter and will not produce a different answer on a second run.
Up to two million characters. Past that it declines with a clear message rather than freezing the tab, because everything runs in your browser and a locked page is a worse outcome than an honest refusal.
No. The tokenizer runs in your browser, nothing is sent to a server, and no part of your document reaches analytics. That is what makes it safe to paste a template that still has keys or customer data in it.