HTML Beautifier
Free online html beautifier for developers. Format and beautify HTML code. Fast and private.
Embed this tool
Copy and paste the code below into your website to embed this tool for free. An attribution link to The Util Box is required.
<iframe src="https://www.theutilbox.org/embed/html-formatter" width="600" height="500" frameborder="0" style="border: none; max-width: 100%;" title="Free HTML Beautifier tool from The Util Box"></iframe> <!-- Free tool by The Util Box — https://www.theutilbox.org/tools/html-formatter --> <a href="https://www.theutilbox.org/tools/html-formatter">HTML Beautifier by The Util Box</a>
Frequently Asked Questions about HTML Beautifier
HTML Formatter — Re-indent Flattened Markup
This HTML formatter takes markup that has been flattened onto one line and puts it back into a readable, indented shape. Paste it in and the tags come out nested with two spaces per level.
It is what you want when you have received minified HTML from a template or an API and need to read it, or when a long single-line file needs to be made navigable.
How the Indentation Is Decided
The markup is split wherever one tag is followed by another, and each piece is placed at the current depth. A closing tag reduces the depth before it is written; an opening tag increases it afterwards. Void elements and self-closing tags do not increase the depth, so they stay at the level of their parent.
Comments and the doctype are left at the left margin.
Honest Limits
- The split is textual, not structural. A
<inside a script, style or textarea block will be read as the start of a tag, and the indentation goes wrong from that point on. - Inline elements are treated as block-level, so a
<span>inside a paragraph starts a new indentation level even though it does not really. - Attributes are left exactly as they are, so single-quoted values and original spacing survive.
- The output is not guaranteed to be valid HTML. It is the same markup, re-indented — the formatter does not check tag balance or add anything that was missing.
Related Developer Tools
- HTML to JSX — convert the markup into a React component.
- HTML Entity Encoder — escape the characters that break a document.
- CSS Formatter — for the stylesheet the markup refers to.
- JavaScript Formatter — for the script blocks.
- Code Minifier — strip the whitespace back out.
- Markdown Editor — for the prose around the markup.
- XML Formatter — the markup equivalent.
- Diff Checker — compare the formatted output with the original.
The formatting runs entirely in your browser — your HTML is never uploaded.