⚡ 107+ free online tools — no sign-up, no watermarks. Explore now →

★ Free Developer Tool

HTML Formatter & Minifier

Beautify messy HTML with clean indentation, or minify it to save bytes. Keeps pre and textarea content exactly.

Loading the tool…

Runs entirely in your browser. Your files and text are never uploaded to our server.

About this toolHTML Formatter re-indents HTML so the structure is easy to read: block elements on their own lines, inline elements kept within text, and void elements like <img> and <br>…
Learn more
  • Instant results
  • 100% free
  • No sign-up
  • Private

HTML Formatter re-indents HTML so the structure is easy to read: block elements on their own lines, inline elements kept within text, and void elements like <img> and <br> handled correctly. Content in <pre> and <textarea> is kept exactly, and scripts and styles are re-indented without being changed.

Minify does the opposite, removing comments and extra whitespace to make the file smaller. Your code is only re-printed, never run. To shrink CSS or JavaScript, use the CSS Minifier or JavaScript Minifier.

More about HTML Formatter & MinifierHow to use, good to know & FAQ

How to use HTML Formatter

  1. Paste HTML or open a file.
  2. Choose the indentation and whether to remove comments.
  3. Click Beautify or Minify.
  4. Copy or download the result.

Good to know

  • Minifying collapses whitespace between words to a single space and removes it around block elements, so the page looks the same.
  • Conditional comments (<!–[if IE]>) are kept when minifying.
  • The formatter doesn’t fix invalid HTML such as missing closing tags. It indents what is there.

Frequently asked questions

Will formatting change how my page looks?

Beautifying only changes whitespace between tags, and browsers treat it the same in almost all cases. Content inside pre and textarea is never changed.

Is my code run or uploaded?

No. It is tokenised in your browser and never executed or sent anywhere.

Can I format PHP or template files?

You can, as long as the HTML parts are well structured. Template tags are treated as text.

When to use HTML Formatter

Use it to read minified page source, clean up HTML copied from editors or emails, or shrink HTML before publishing.