HTML Minifier & Beautifier
Minify HTML to reduce file size, or beautify it for readability — with inline CSS & JS support
Mode
Options
Remove HTML Comments
Strips <!-- ... --> comment blocks
Collapse Whitespace
Reduces multiple spaces/newlines to one
Remove Empty Lines
Deletes blank lines from the output
Minify Inline CSS
Compresses <style> block content
Minify Inline JS
Compresses <script> block content
Remove Safe Quotes
Removes quotes from simple attribute values
HTML Input(0 chars)
Minified Output(0 chars)
Free Online HTML Minifier & Beautifier — Compress and Format HTML Instantly
Page load speed is one of the most important factors for both user experience and search engine ranking. Every byte that your web server sends to the browser adds to load time. One of the simplest ways to reduce your HTML file size is through minification — removing whitespace, comments, and other characters that browsers don't need but that developers use to keep their code readable.
The OmniWebKit HTML Minifier strips unnecessary whitespace, collapses multiple spaces into one, removes HTML comments, and can also minify inline CSS within <style> blocks and inline JavaScript within <script> tags. All six minification options are individually toggleable, so you have full control over what gets stripped.
The tool also includes an HTML Beautifier mode — the opposite of minification. If you receive minified HTML (from a production build, a CMS export, or a web scraper) and need to read or edit it, the beautifier re-indents the markup with proper nested structure, making it human-readable again. Choose between 2-space, 4-space, or tab indentation.
What Each Minification Option Does
Remove HTML Comments
HTML comments (<!-- ... -->) are useful for developers but invisible to users and unnecessary in production. This option strips all comment blocks from the markup. Conditional comments (used for old IE) would also be removed, so only enable this if you are not targeting Internet Explorer.
Collapse Whitespace
HTML ignores extra whitespace between tags and within text, so the spaces you add between elements for readability serve no functional purpose in the rendered output. This option reduces sequential whitespace characters (spaces, tabs, newlines) to a single space. It also removes whitespace between adjacent tags (> < becomes ><), which is the single most effective size reduction for most HTML documents.
Remove Empty Lines
Blank lines used for visual grouping in your source code have no effect on how the page renders. This option removes them from the output. On large HTML files with many blank lines between sections, this can reduce character count noticeably.
Minify Inline CSS
Any CSS code inside <style> tags is also minified: CSS comments are removed, whitespace is collapsed, and redundant semicolons and spaces around colons and braces are eliminated. This is particularly useful for HTML emails or single-file HTML pages with embedded styles.
Minify Inline JS
JavaScript inside <script> tags has its single-line comments (//) and multi-line comments (/* */) removed, and its whitespace collapsed. This is a basic minification — it does not rename variables or perform dead-code elimination like a full JS bundler would, but it still reduces character count significantly for simple scripts.
Remove Safe Quotes
HTML5 allows attribute values to omit quotes if the value contains only letters, numbers, hyphens, and underscores. For example, class="container" can become class=container. This option applies that optimisation where it is safe to do so. Disable it if your HTML needs to be XHTML-valid.
How HTML Minification Improves Page Speed
When a user visits your webpage, their browser sends an HTTP request to your server. The server responds by sending the HTML document, which the browser then parses to start building the page. Every unnecessary character in that HTML adds to the time it takes to transfer the document over the network — this is the document's "transfer size."
Google's Core Web Vitals — specifically Largest Contentful Paint (LCP) and First Contentful Paint (FCP) — are directly impacted by how quickly the browser can receive and begin parsing the HTML document. A smaller HTML file starts painting the page sooner. For pages on fast connections, the difference might be measured in milliseconds. But on slower mobile connections or emerging markets, it can meaningfully reduce time-to-interactive.
HTML minification works alongside Gzip or Brotli compression (applied by your web server). Gzip already compresses repetitive text patterns very efficiently, which means minification provides less additional benefit for files that are already Gzip-compressed — but it still helps. Minification reduces the size before compression, and the resulting compressed file is also smaller.
For static sites, HTML files should be minified as part of the build process using tools like gulp-htmlmin, html-minifier-terser, or the built-in minification of frameworks like Next.js. This tool is ideal for one-off minification, quick testing, or when you need to minify HTML that isn't part of an automated build pipeline.
