HTML formatter and minifier

Paste HTML to indent it so the structure is clear, or switch to Minify to remove the whitespace between tags. Code inside pre, textarea, script and style is never touched.

Mode
Indent

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Paste HTML into the left box.
  2. Choose Beautify for readable code or Minify for the smallest output.
  3. For Beautify, pick 2 spaces, 4 spaces or a tab, then copy the result.

How beautify lays things out

  • Block elements (div, p, ul, li, h1…, and unknown or custom elements) each start on a new line, indented one level deeper than their parent.
  • A block that holds only text and inline elements stays on one line when it fits in 100 characters; longer text is wrapped at the spaces that were already there.
  • Attributes are separated by single spaces; their values and quotes are not changed.
  • Void elements such as br, img and meta have no closing tag.

Tips

Minifying inline <script> or <style> content is out of scope here: those blocks are copied unchanged. Use the JavaScript minifier on script contents first if you need that.

Frequently asked questions

Does formatting change how the page looks?

It is designed not to. Tags are never added, removed or reordered. Text and inline elements such as a, b, em and span stay together on a line with the same single spaces between words, which is how browsers collapse whitespace anyway.

What is kept exactly as written?

Everything inside pre, textarea, script and style, including spaces and line breaks. Only the tags around them are placed and indented.

What does minify remove?

Comments (except conditional comments like <!--[if IE]>), whitespace between block elements such as div, p and li, and repeated spaces in text. A single space between inline items is kept because it is visible.

Does it fix broken HTML?

No. It does not add missing closing tags or repair nesting; an unclosed element simply stays unclosed and its content is indented under it.

Is my HTML sent anywhere?

No. The formatter runs entirely in your browser.

More in Developer

All tools in this category: Developer ·Updated November 3, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.