AI Tools Free

HTML Minifier

Minify HTML fragments or documents locally while preserving script, style, pre, and textarea content.

Free to useNo sign-upRuns in your browser
Enter your details

Enter the inputs, then select Minify HTML.

Your result
Enter your details

Result will appear here

How HTML Minifier works

The minifier conservatively reduces HTML whitespace and optionally removes ordinary comments while retaining attribute quotes, optional tags, and embedded script or style content.

The result reports original and output UTF-8 byte sizes. Review the actual rendered document after copying it; inline JavaScript and CSS are not separately minified.

The input must contain text and stay within 100000 characters.

Spaced HTML markup connected to a more compact text representation.
Illustration of the HTML Minifier workflow.

How to use HTML Minifier

Paste the HTML source and choose whether ordinary comments should remain in the output.

Supply HTML and comment handling

Paste the document or fragment and choose whether ordinary HTML comments should remain. Keep a source copy for a rendered comparison, especially when whitespace carries meaning in the document.

HTML
HTML Minifier native input panel with the actual HTML, HTML comments settings used for this example.
Configure HTML, HTML comments; select Minify HTML.

Minify and read byte totals

Run the minifier and inspect the output-byte result with original bytes, bytes saved, and reduction. These values describe this particular source, not a general speed improvement.

131 bytes
HTML Minifier actual result panel showing 131 bytes.
Submitted result: 131 bytes. Original bytes: 168.

Copy and test the document

Copy the minified HTML and review it in its intended page. The result note explains that inline CSS and JavaScript are not minified. Check whitespace-sensitive and preformatted areas before replacing a file.

Output and export
HTML Minifier actual output and export region and result note after submitting the pictured settings.
Review the actual HTML Minifier output and visible Copy result controls. Read the result note.

When to use HTML Minifier

Minify a reviewed source fragment before checking it in its actual rendering context.

Prepare an HTML fragment

Minify a reviewed fragment for a system that accepts HTML text, then check that system output separately. Keep the original readable fragment as the editing source. A compact copy is less suitable for continuing manual edits or discussing markup structure.

Developer input and configuration represented by document cards.
Prepare the input. Concept illustration.

Compare source size

Use the reported UTF-8 byte counts to compare this source before and after processing. Those counts describe the markup only. They do not include images, network compression, external stylesheets, or the other resources that affect actual page loading.

A developer example flowing from input to reviewed output.
Inspect an example. Concept illustration.

Review a build step

Try a representative source sample when evaluating a minification step in a build process. Include markup where whitespace matters, rather than testing only empty structural tags. The local result can expose a review concern but is not an integration test of that build.

Developer output handed to the next stage of a workflow.
Use the result in your workflow. Concept illustration.

Read HTML minification scope and preserved content

Compare the compact HTML with the original where whitespace, comments, or embedded content may matter.

Attribute quotes and optional tags are retained by this conservative configuration. Embedded JavaScript and CSS are not minified, so their size and behavior are outside the reported HTML transformation.

Whitespace reduction can affect meaningful separation in some markup or template contexts. A smaller output is not enough to establish that the page still communicates or behaves correctly.

A developer result reviewed alongside its source.
Review the returned output. Concept illustration.

Check failed or changed output

Test the resulting document in its intended page after checking the source and comment option.

The input must contain text and stay within 100000 characters. Work runs with a time budget. If a large source is stopped, isolate a representative complete fragment for inspection.

If rendering changes, compare the source and output around inline text and template expressions. Return to the original before editing, and test the chosen minification settings in the actual application.

Input format and assumptions reviewed for a developer task.
Check format and assumptions. Concept illustration.

Minify an HTML document or fragment

Paste the HTML source and choose whether ordinary comments should remain in the output.

Minify HTML

HTML Minifier: common questions

Answers about using HTML Minifier and understanding its results.

Are preformatted blocks changed?

Whitespace inside pre and textarea elements is preserved.

Does it execute pasted scripts?

No. The tool treats the input and result as text in an isolated processing worker.

Does it minify inline JavaScript and CSS?

No. Script and style content is retained; those languages are not minified by this tool.

Can I control ordinary comments?

Yes. Choose Keep or Remove ordinary comments before running the minifier.