HTML Minifier

HTML Minifier - Minify HTML Online

Minify HTML online with html-minifier-terser. Paste markup or choose a .html or .htm file, then copy or download a separate minified file. Your code stays in your browser.

Only UTF-8 source files are supported, up to 5 MiB. UTF-16 files and a conflicting declared charset are refused. Downloads use UTF-8.

Minify options

Ready. No HTML leaves your browser.

The original input is not changed. Review and test the output before publishing.

How to minify HTML online

  1. Add your document

    Paste markup or select a .html or .htm file. The file is read locally and must be UTF-8.

  2. Choose options and minify

    Pick the options you need, then click Minify HTML. Whitespace collapsing is conservative, so a single space stays between inline content.

  3. Copy or download

    Copy the output or save it as a separate .min.html or .min.htm file. The original file is left untouched.

Paste markup or choose a .html or .htm file, click Minify HTML, inspect the output, then copy it or save a separate minified file such as index.min.html.

When to use this HTML minifier

Use it to prepare a smaller HTML file for a static site, to inspect the difference between source and compact markup, or to create a separate release copy without editing the original document.

Limitations

Whitespace collapsing is conservative: runs of whitespace become a single space instead of disappearing. Whitespace inside <pre> and <textarea> is preserved exactly, while inside <script> and <style> only the surrounding whitespace is trimmed. Ordinary comments are removed, while comments starting with !, server-side directives starting with #, and conditional comments are kept. Inline CSS and JavaScript minification is off by default. CSS minification only touches inline <style> blocks and style attributes; JavaScript minification only touches inline <script> blocks. Neither renames identifiers, compresses expressions, or changes external files. Malformed markup is repaired rather than rejected, so confirm the structure still matches your intent. The tool does not validate your HTML or fetch linked assets. Input is limited to 5 MiB and must be UTF-8; UTF-16 files and a conflicting declared charset are refused. Minification runs off the main thread in a worker with a hard time limit, so a document that stays busy past that limit is stopped.

HTML Minifier FAQ

Is my HTML uploaded?

No. Selected files and pasted markup are processed locally in your browser. Loading the page itself still makes ordinary website requests.

Does it render or run my markup?

No. Your input is treated as text and shown in a textarea; it is never rendered or executed in your browser.

Which files can I minify?

.html and .htm files, encoded as UTF-8, up to 5 MiB. UTF-16 files and files whose declared charset is not UTF-8 are refused.

Will it delete my comments?

Ordinary comments are removed when the option is on. Comments starting with !, server-side directives starting with #, and conditional comments are kept.

Is the original file changed?

No. Download creates a separate .min.html or .min.htm copy; rename it as needed.