Dev TooloraLocal dev tools

> Formatters

HTML Formatter & Minifier

Format or minify HTML locally. Block elements are indented, and pre, textarea, script and style content is kept byte for byte.

Runs locallyWorks offline
Back to results
Input

Source data

Mode
Indentation
Output

Result

Your result will appear here.

Tool guide

About this tool.

Formatting puts each block element, such as div, p or li, on its own indented line. Inline elements such as b, a or span stay on the line of their text.

The tool uses its own small tokenizer instead of a browser DOM, so attributes, quotes and tag case are copied exactly as written.

Minify removes comments and the whitespace between tags. Conditional comments that start with <!--[if are kept. Optional closing tags and attribute quotes are never removed.

Paste HTML or choose a sample.

Choose Format to indent the markup, or Minify to remove comments and layout whitespace.

Pick 2 spaces, 4 spaces or tabs for Format mode.

Copy the result or save it as an HTML file.

  • <div><p>Hi <b>there</b></p></div> → div on its own line with the p indented inside it.
  • <pre> a b</pre> → unchanged in both modes.
  • <div><span>x</div> → </span> is added and the summary reports 1 unclosed element closed.
  • <ul> <li>a</li> <!-- c --> </ul> → <ul><li>a</li></ul> in Minify mode.

  • Processing is local; nothing is uploaded.
  • Limits: 5,000,000 input characters, 100 nesting levels and 100,000 nodes.
  • Format mode collapses whitespace inside inline runs and trims it at their edges; a / on a non-void tag such as <div/> is treated as self-closing.
  • Implied end tags (p, li, dt, dd, td, th, tr, option) stay implied. Other unclosed elements are closed at their parent’s end; stray closing tags are kept as written.

FAQ

Questions about HTML Formatter & Minifier

Does it change my scripts or preformatted text?

No. Content inside pre, textarea, script and style is copied byte for byte in both modes, even when a script contains text like "</div>".

Does it reject broken HTML?

No. Malformed HTML is not an error. Unclosed elements are closed at the end of their parent, and the summary tells you how many were closed.

Does it validate HTML?

No. It does not check HTML conformance or fix invalid nesting beyond closing unclosed elements.

Are comments kept?

Yes, conditional comments that start with <!--[if are kept. All other comments are removed in Minify mode and kept in Format mode.

Can minify join words together?

Whitespace between two inline elements is kept as one space so words stay apart. Whitespace next to block elements is removed.

Continue with

XML FormatValidate and indent XML while preserving attributes, mixed text, CDATA and xml:space content.HTML EntitiesEscape HTML syntax characters or decode named, decimal and hexadecimal character references as plain text.Markdown to HTMLConvert Markdown into real HTML with a local visual preview, explicit syntax options and exact file export.