Code Minifier
Minify JavaScript with Terser, CSS with CSSO and HTML with inline CSS and JS, and see how much smaller each file gets.
Runs in your browser. Nothing is uploaded.
How to use the Code Minifier
- Choose JavaScript, CSS or HTML with the switch at the top.
- Paste code into the left box, open a file, or press Load example. The minified code appears on the right with the size saved.
- Adjust the options for that language, such as shortening names, merging CSS rules or minifying inline scripts.
- Copy the result or download it with a
.minfile name, ready to upload.
Smaller files, faster pages
Every byte a page downloads costs time, especially on mobile connections. Minifying removes what browsers don’t need, such as whitespace, comments and long names, without changing what the code does. Build tools do this automatically, but plenty of sites are made without one: a landing page, a theme tweak, a script for a CMS, or a quick experiment. Choose the language, paste the code and copy the minified version.
JavaScript
Terser parses the code and rewrites it for size. Shorten names renames local variables and
functions to single letters. Rewrite for size applies safe transformations, such as removing
unreachable code and joining declarations. Remove console calls strips console.log and similar
calls for production. Syntax errors are reported with their line and column.
CSS
CSSO removes whitespace and comments, shortens colours and values (#ffffff becomes #fff, 0px
becomes 0), and with Merge rules combines selectors and declarations that repeat, which often saves
more than whitespace alone.
HTML
The HTML minifier collapses whitespace between tags while keeping it where it matters, such as inside
<pre> and inline text. It can remove comments, minify inline <style> and <script> blocks with the
CSS and JavaScript minifiers, and optionally drop optional closing tags and attribute quotes for the
smallest result.
Check the result
The message under the boxes shows the size before and after. Keep the original file: minified code is hard to edit, and to read it again you can run it through the Code Formatter.
Frequently asked questions
Which minifiers does it use?
Terser for JavaScript, CSSO for CSS and html-minifier-terser for HTML, the same tools used by popular build systems. They run in your browser, so the result matches what a build step would produce with the same options.
Will minified code still work?
Yes, minifiers only make changes that keep the behaviour the same. Two settings deserve care: Remove console calls drops logging you might rely on, and Drop optional tags and quotes in HTML produces valid but unusual markup that some tools mishandle.
Why keep licence comments?
Many open-source licences require their notice to stay with the code. Comments starting with /*! or containing @license or @preserve are kept unless you untick the option.
How much smaller will my files get?
Typically 30–60% for JavaScript and 15–30% for CSS and HTML, before gzip. Servers usually compress files as well, so the saving over the network is smaller but still worthwhile.
Is my code uploaded?
No. Minification runs in a background worker in your browser.
Tutorials
How to minify a JavaScript file for your website
Shrink a hand-written script before you upload it, keep its licence comment and check how much smaller it gets.
How to minify an HTML landing page
Shrink a landing page with inline CSS and JavaScript, remove comments and default attributes, and check the saving before publishing.
How to shrink a stylesheet before uploading it
Minify a hand-written CSS file, keep its licence comment, merge duplicate rules and check the saving before you upload it.