HTML Formatter Minifier screenshot

HTML Formatter Minifier

Beautify or minify HTML code.

Privacy First
0 Runs
Updated 2026-11-06
Runs in your browser
Nothing uploaded
No account needed

Beautify or minify HTML code. Enter your numbers and get an instant result.

Paste markup and this page indents it tag by tag, with two spaces, four spaces or a minified single line. Text between tags is kept; the whitespace between tags is what changes.

It walks angle brackets, so it does not repair broken markup and it does not check that the document is valid. A div that is never closed shifts every following line, and the page reports nothing.

The rewrite happens in the tab. Nothing is uploaded and no request is made for an external resource named in the markup.

What the indenter knows

An opening tag raises the indent, a closing tag lowers it, and a known set of void elements is left alone so that a br or an img does not swallow everything after it. The set is br, hr, img, input, link and meta.

Minify removes whitespace between tags and collapses runs of whitespace in the text, then trims the ends. That is a genuine change to rendered spacing in inline contexts, so keep the beautified version if the layout depends on it.

  • Void elements are not indented as containers
  • Whitespace between tags is discarded in minified mode
  • Text inside an element is preserved in beautified mode

Where a formatter stops and a parser starts

If the page needs to be correct, run it through an HTML validator. This formatter cannot tell you that a table cell is outside a row or that an attribute is misspelled, and an indent that looks right is not evidence that the document is well formed.

Mixed content is again the caveat: an element holding both text and children is indented by tags, so the text can move onto its own line. Inline layout that depends on a space can change as a result.

How to use the format buttons

Paste the markup into the Raw HTML pane and press Format (2 Space), Format (4 Space) or Minify HTML; the Output pane shows the re-indented document. Text between tags is kept and the whitespace between tags is what changes, with the same void set as the XML page left alone.

Minify removes whitespace between tags and collapses runs inside the text, which genuinely changes rendered spacing in inline contexts, so keep the beautified version when layout depends on it. Broken markup is indented, not repaired: a div that never closes shifts every line after it with no error.

What to Expect

Best for

  • Making a pasted fragment readable
  • Producing a single-line snippet for a template string
  • Comparing two fragments once the indentation matches

Not ideal for

  • Validating markup
  • Repairing unclosed or mismatched tags
  • Markup where a collapsed space changes the layout

What this tool keeps

  • Tags and attributes as written
  • Text inside elements in beautified mode
  • The document order of the elements

What may need cleanup

  • Indentation after an unclosed tag, which cascades to every following line
  • Inline spacing after minifying
  • Custom elements and templates that are not in the void-element set

Common errors

  • Expecting an indented result to mean valid markup
  • Minifying markup that relies on a space between inline elements
  • Forgetting that a self-closing custom tag is treated as a container

Example use cases

  • Reading a minified email template
  • Preparing a fragment for a test fixture
  • Re-indenting a snippet before pasting it into a ticket

Sample input

Paste <div><p>Hello World</p><span>AllTools</span></div> and choose two spaces.

Sample output

The div on its own line, with the paragraph and the span nested one level deeper.

Who this is for

  • Developers reading minified markup
  • Anyone preparing a fragment for a template
  • Test authors diffing two snippets

Frequently asked questions

What changes when this page formats HTML?

The whitespace between tags is re-indented; the tags, attributes and text inside elements are kept as written.

Can it repair an unclosed or mismatched tag?

No. An unclosed tag makes the indentation cascade through the rest of the document, so fix the markup before formatting.

Is minified output safe for markup where a space matters?

Not always. Minifying collapses spacing, so markup whose layout depends on a removed space should stay in beautified mode.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.