HTML Formatter & Minifier.
Beautify HTML with clean indentation or minify it, without touching pre, textarea or script contents.
Runs in your browserAbout HTML Formatter & Minifier
The HTML Formatter takes markup that arrives on one long line, from a CMS export, an email template or a View Source copy, and puts every block element on its own line with consistent indentation. Inline content such as links, bold text and spans stays on the line it belongs to, so a paragraph still reads as a sentence. Minify mode does the opposite: it removes comments and the whitespace between block elements and collapses runs of spaces, which typically saves 5–20% before gzip. The tool is careful about whitespace that the browser actually renders. A space between two inline elements, as in "<b>bold</b> <i>italic</i>", is kept, and no space is invented where there was none. Text inside pre, textarea and title is copied byte for byte, and script contents are never re-indented, so template literals and regular expressions keep their meaning. Every result is checked against the input before it is shown: if the tags, attributes or rendered text would differ, you get an error instead of a silently broken page. For example, "<ul><li>One<li>Two</ul>" becomes a nested list with each li on its own line; the omitted closing tags stay omitted, because adding them is not the formatter's job. Typical mistakes it surfaces are an unterminated attribute quote, such as class="btn without the closing quote, and an unclosed comment; both are reported with a line and column. The formatter does not validate HTML against the spec and does not reorder or rewrite attributes. Everything runs in your browser, with no upload.
How to Use
- Paste your HTML into the input field.
- Choose Format or Minify and the indentation width.
- Copy or download the result.
Frequently Asked Questions
Will formatting change how my page looks?
It should not. The formatter only changes whitespace that browsers ignore (between block elements and at the start or end of a block) and checks the result against the input before showing it. Content inside pre and textarea is never changed.
Does it format the CSS and JavaScript inside the page?
Style blocks are re-indented to match the surrounding markup; script blocks are kept exactly as written, because changing indentation inside JavaScript template literals would change the program. Use the CSS formatter for stylesheets.
Why are some closing tags missing in the output?
HTML allows you to omit closing tags such as </li>, </p> and </td>. The formatter keeps your markup as written and only changes the layout.
Is my HTML uploaded anywhere?
No. Formatting runs in your browser; the page makes no network requests while you use it.
Related Tools
Beautify CSS with one declaration per line or minify it safely, including nested rules and media queries.
Format, minify, and validate XML.
Render Markdown to HTML with live preview.
Encode and decode HTML entities.
Shrink SVG files by removing editor junk, metadata and comments and by rounding coordinates.
Pretty print, minify, and validate JSON.