A
AracBox
Tools
All Tools

Developer Tools

HTML Formatter and Minifier

Indent markup for readability or reduce whitespace between tokens. This formatter/minifier transforms text; it does not parse or validate HTML.

πŸ”’ HTML is processed as text and is not injected into the page.

About this tool

Indent markup for readability or reduce whitespace between tokens. This formatter/minifier transforms text; it does not parse or validate HTML.

What is it?

Formatting puts tokens on lines and indents nested tags; Minify collapses whitespace within tokens and between adjacent tags. Neither action is an HTML parser or validator.

How to Format or Minify HTML Text

Paste markup, choose an indent size, and select Format or Minify. The result is shown in a textarea; inspect especially malformed markup and script/style content before reusing it.

  1. Paste HTML-like text into the input area.
  2. Choose an indentation size and use Format for a line-oriented, indented view.
  3. Use Minify to collapse whitespace and remove whitespace between adjacent tags.
  4. Inspect the text result: this tokenizer does not parse or validate HTML.

Examples

  • Format: <div><p>Hello</p></div> β†’ <div> <p> Hello </p> </div>
  • Minify: <p title="a b">A & B</p> β†’ <p title="a b">A & B</p>
  • Minify: <!-- note --> <img src="x"><br> β†’ <!-- note --><img src="x"><br>

Common use cases

  • Scanning nested tags in pasted snippets by indentation.
  • Reducing whitespace in simple markup before comparing or copying it.
  • Reviewing a text transformation without running the supplied markup.

Technical details

  • A lightweight tokenizer splits at the next > after each <; it is not an HTML parser or validator.
  • Formatting places tokens on lines, indents nested non-void start tags, and collapses whitespace within text tokens.
  • Minification collapses whitespace in every token and removes whitespace between adjacent tags. Comments are retained; attribute quotes are not deliberately rewritten.
  • Inline/block and raw script/style content receive no special handling; a < inside script text can be treated as a tag boundary.
  • Empty or whitespace-only input shows an error. Malformed input may still produce output, which is not proof of valid HTML.

Related concepts

Tokenization Indentation Whitespace collapsing HTML validation

How Does the HTML Formatter and Minifier Work?

Formatting puts tokens on lines and indents nested tags; Minify collapses whitespace within tokens and between adjacent tags. Neither action is an HTML parser or validator.

Frequently Asked Questions

Does the formatter parse or validate HTML?

No. A lightweight tokenizer splits at the first > after each < and may still produce text output for malformed input. The result is not a validity guarantee.

How are whitespace, attributes and comments handled?

Formatting collapses whitespace in text tokens and leaves attribute text unchanged. Minify collapses whitespace in all tokens and keeps comments; it does not deliberately change quote style.

Are inline elements or script/style content handled specially?

No. There is no inline/block or raw script/style distinction; a < in script text can be treated as a tag boundary, and whitespace is collapsed. Inspect the result.

Is the input executed or uploaded?

No. Processing runs in the browser and the result is shown as text in a textarea; source HTML is not sent to the server or analytics.

Related Tools