HTML Formatter & Beautifier
Format, beautify, or minify HTML online. Indent nested tags, optionally sort attributes alphabetically, and clean up markup exported from a CMS or minified for production.
The formatting library downloads on first use, so a short delay is normal. Minify also compresses content inside <pre>/<script> blocks; use caution where whitespace is significant.
Why format HTML?
HTML that's been minified for production, generated by a template engine, or copy-pasted from a browser's "View Source" often comes out as one dense block with little or no indentation. Reformatting it restores a clear visual hierarchy — you can immediately see which elements are nested inside which — making it much easier to read, debug, and hand-edit.
What this tool does
- Beautify — reindents nested elements using Prettier's HTML printer, the same engine used by many code editors.
- Sort attributes — alphabetizes each tag's attributes, purely for readability; it has no effect on rendering.
- Minify — strips comments and collapses whitespace between tags to reduce file size.
Example
| Minified | Beautified |
|---|---|
<div class="a" id="b"><p>Hi</p></div> | <div class="a" id="b"> |
Frequently asked questions
How do I format HTML online?
Paste your HTML into the input box and click Beautify. The formatter reindents nested tags instantly using Prettier, so the markup structure is easy to read.
How do I beautify HTML?
Beautifying HTML restores indentation to minified or single-line markup. Click Beautify, optionally enable attribute sorting, and the beautifier reformats your HTML immediately in the browser.
Will formatting break my HTML?
No, beautifying only changes whitespace between tags — it doesn't add, remove, or reorder elements or attributes (unless you explicitly enable attribute sorting). The rendered page looks identical before and after.
Does this tool validate my HTML?
It uses Prettier's HTML parser, which is lenient like a browser and will format most real-world markup, including some technically invalid HTML. It is not a strict validator; for standards compliance checking, use a dedicated HTML validator.