Minified markup
Paste <div><p>Hi</p></div> and Beautify spreads it across 3 lines with the default 2-space indentation, with the <p> tag indented one level inside <div>.
Beautify and format messy HTML online with proper indentation — free HTML formatter.
About
Paste minified or badly indented HTML and get it back readable, with line breaks and indentation added between block-level tags — without changing what's inside <pre>, where whitespace actually matters, or reformatting the code inside <script> and <style>.
Nested tags are indented one level per depth, so a missing </div> or a tag closed in the wrong place stands out as soon as the indentation drifts. Inline elements like <a>, <span> and <strong> stay inside their line of text instead of being split onto lines of their own.
Examples
4 worked examples
Paste <div><p>Hi</p></div> and Beautify spreads it across 3 lines with the default 2-space indentation, with the <p> tag indented one level inside <div>.
Paste <ul><li>A</li><li>B</li></ul> and it comes back as 4 lines, with each <li> indented under its <ul>.
Paste <pre> keep spacing </pre> and the whitespace inside the <pre> tag is left completely untouched — only the surrounding tags get re-indented.
<div><p>Hi</p><pre> a</pre></div> is split so the <p> and <pre> each sit on their own line inside the indented <div>, with the spacing inside <pre> left exactly as it was.
FAQ
Quick answers to common questions about the HTML Beautifier.
Paste your HTML code above, make sure HTML is selected, then click Beautify. The formatted output appears in the box below it — everything runs in your browser, using js-beautify.
Yes. It's free, with no sign-up and no limit on how much code you format.
Yes — that's one of its most common uses. Paste minified or exported markup in and it comes back with proper nesting and indentation between block-level tags.
Content inside <pre> is left exactly as it is, since whitespace there is meaningful. <script> and <style> blocks are moved onto their own indented lines, but the code inside them isn't reformatted — use the JavaScript or CSS Beautifier for that.
No. Formatting runs entirely in your browser after js-beautify loads from this site — your code never leaves your device.
Yes — switch the language dropdown, or use the dedicated JavaScript beautifier or CSS beautifier page.
Yes — choose anything from 1 to 8 spaces in the Indent size box before you click Beautify. Two spaces is the default.
No. It re-indents the markup as written; it doesn't add missing closing tags or correct invalid nesting. Check structure problems with your editor or an HTML validator.
No — only the line breaks and indentation between tags change. Attributes, their quotes and your text are kept as they are.
Did HTML Beautifier work for you?