Format or minify HTML markup with predictable indentation and readable structure.
Loading tool
About HTML Beautify / Minify
Pretty-print an HTML document or fragment with 2, 4 or 8 spaces or tabs, including inline <style> and <script> blocks, or minify it. Beautify uses js-beautify; minify removes comments (except conditional comments), collapses whitespace between block elements and inside tags, and minifies inline CSS and JavaScript, while leaving <pre> and <textarea> content as-is.
Common uses
- Make minified or generated HTML readable before inspecting or editing it.
- Normalize indentation of a template before committing it.
- Compact a static HTML snippet or email template to reduce its size.
- Format markup copied from browser DevTools.
FAQ
- Can minifying HTML change how a page looks?
- Whitespace between inline elements can be visible, so aggressive whitespace removal can occasionally close a gap between words or inline elements. Content inside <pre> and <textarea>, where whitespace matters, is preserved by this tool.
- Does the beautifier fix invalid HTML?
- No. It re-indents the markup it is given; it does not validate it or add missing closing tags.