Skip to content
zspace tools

Developer Tools

HTML Formatter & Minifier

Paste or open HTML to beautify it with consistent indentation, or minify it to cut file size. Keep or strip comments, see the size difference, check for unclosed tags, and download the result.

Runs in your browser

Features

What you get

  • Beautify

    Consistent indentation with 2 spaces, 4 spaces or tabs; nested elements on their own lines.

  • Minify

    Removes whitespace between tags and, optionally, comments — with a before/after size comparison.

  • Safe for code blocks

    <pre>, <textarea>, <script> and <style> contents are preserved exactly.

  • Structure checks

    Flags unclosed tags, stray closing tags and closing tags on void elements, with line numbers.

  • Comments and blank lines

    Choose whether to keep <!-- comments --> and the blank lines between sections.

  • Open, copy, download

    Open an .html file, copy the result or download it as index.html or index.min.html.

How to use

How to use the HTML Formatter & Minifier

The HTML is read by a tokenizer that understands tags, attributes, comments, doctype and void elements like <img> and <br>, and builds a tree — closing <p> and <li> implicitly where HTML allows. Beautify prints that tree with your chosen indentation; short inline content stays on one line. Minify collapses whitespace between tags and inside text. The contents of <pre>, <textarea>, <script> and <style> are always left exactly as written. Your HTML is treated only as text: it's never rendered, and scripts in it never run.

  1. 01

    Add your HTML

    Paste it, open an .html file, or load the sample.

  2. 02

    Beautify or minify

    Pick an action, indentation and comment options. The output updates as you edit.

  3. 03

    Check and export

    Review any structure warnings and the size change, then copy or download.

Examples

Worked examples

  • One-line markup

    <ul><li>One<li>Two</ul> beautifies to a <ul> with two indented <li> lines, each closed properly.

  • Minify a page

    A 3 KB hand-written page with indentation and comments typically shrinks by 15–30% — the exact figure is shown for your file.

  • Catching mistakes

    <div><span>Hi</div> is reported as “<span> opened on line 1 is never closed”.

Technical specifications

Indentation
2 spaces, 4 spaces or tab
Preserved as-is
<pre>, <textarea>, <script>, <style>
Checks
Unclosed, stray and void-element closing tags
File types
.html, .htm (up to 5 MB)
Output
Copy or download .html
Rendering
Never — input is treated as text

Privacy

HTML is formatted in your browser and never sent, stored, rendered or executed.

Read the full privacy policy.

FAQ

HTML Formatter & Minifier questions

An HTML formatter (or beautifier) re-indents HTML so its structure is easy to read; a minifier removes unnecessary whitespace and comments to make the file smaller. ZSpace Tools' HTML Formatter & Minifier does both, and also points out common structural problems such as unclosed or stray tags.

The HTML is read by a tokenizer that understands tags, attributes, comments, doctype and void elements like <img> and <br>, and builds a tree — closing <p> and <li> implicitly where HTML allows. Beautify prints that tree with your chosen indentation; short inline content stays on one line. Minify collapses whitespace between tags and inside text. The contents of <pre>, <textarea>, <script> and <style> are always left exactly as written. Your HTML is treated only as text: it's never rendered, and scripts in it never run.

It shouldn't for normal block layout, but whitespace between inline elements (like two <a> tags) can matter in HTML. The formatter keeps short inline runs on one line to minimise this; check pages where spacing between inline elements is critical.

Yes for typical pages — only whitespace between tags, runs of spaces and (optionally) comments are removed, and <pre>, <textarea>, <script> and <style> are untouched. Conditional comments and server templates may need comments kept.

It checks common structural problems — unclosed tags, stray closing tags and closing tags on void elements. It isn't a full W3C validator and doesn't check attributes or content models.

No. Script and style contents are kept exactly as written. Use the CSS Minifier for stylesheets.

Yes. The tool never renders your HTML or runs its scripts — it's only processed as text.

No. Formatting happens entirely in your browser.