HTML Formatter & Minifier

Beautify messy HTML with clean indentation, or minify it and see the bytes saved.

The HTML Formatter beautifies raw or minified HTML with clean, consistent indentation, and minifies it back down for production — reporting exactly how many bytes you saved. The contents of pre, script and style tags are preserved so nothing breaks.

  • Beautify messy or minified HTML
  • Minify and see the bytes saved
  • Configurable 2 / 4 / 8-space indentation
  • 100% private — runs in your browser

Beautify or Minify HTML

Paste raw or minified HTML and it's beautified with consistent indentation as you type. Click Minify to collapse whitespace and strip comments — the content of <pre>, <textarea>, <script> and <style> is preserved so nothing breaks. Everything runs locally in your browser.

How to Format HTML Online

  1. 1Paste raw, exported or minified HTML into the input panel
  2. 2Choose 2, 4 or 8-space indentation
  3. 3Click Format to beautify, or Minify to compress it
  4. 4Copy or download the result

Example

Input (single line):

<div class="card"><h2>Title</h2><p>Some <b>text</b> goes here.</p><ul><li>One</li><li>Two</li></ul></div>

Output (formatted, 2 spaces):

<div class="card">
  <h2>Title</h2>
  <p>Some <b>text</b> goes here.</p>
  <ul>
    <li>One</li>
    <li>Two</li>
  </ul>
</div>

Features

Clean indentation

Nested elements are consistently indented, however deep the markup goes.

Configurable indent size

Switch between 2, 4 or 8 spaces to match your project's style.

Preserves special tags

pre, textarea, script and style content is left exactly as-is — no accidental breakage.

Minify with bytes saved

Collapse whitespace and strip comments, and see exactly how much smaller the output is.

Keeps IE conditional comments

Standard comments are stripped on minify, but IE's [if ...] conditional comments are kept.

100% private

Formatting and minifying run entirely in your browser — nothing is uploaded.

Who Uses This

  • Frontend developersclean up HTML exported from a design tool, CMS, or scraped from a live page before editing it.
  • Backend developersformat server-rendered templates (Django, Rails, PHP, JSP) that arrive as one long minified line.
  • Email developersbeautify table-based HTML email templates to make them readable during review.
  • DevOps and build pipelinesminify static HTML before deployment and confirm exactly how many bytes were saved.

Frequently Asked Questions

No. The minifier protects the contents of pre, textarea, script and style tags, so code and preformatted text are left intact while surrounding whitespace is collapsed.

No. Beautifying and minifying happen entirely in your browser — nothing is sent to a server.

Yes. Choose 2, 4 or 8 spaces from the indent selector; the output reformats instantly.

Yes. Standard HTML comments are removed on minify, but IE's conditional comments (the ones starting with [if ...]) are preserved.

No. It's a formatter, not an HTML repair tool — it reflows valid markup but doesn't parse-correct broken or mismatched tags.

Yes. Paste an entire document and it beautifies the whole structure, including embedded scripts and styles.

No. Only whitespace and line breaks are adjusted — attribute order, quoting and values are left exactly as you wrote them.

Related Tools