JavaScript Minifier online: shrink JS, CSS & HTML
The minifier makes JavaScript, CSS, and HTML smaller without changing how they work: it removes comments and whitespace and shortens local JavaScript names. For example, the JavaScript sample below shrinks from 324 B to 180 B. Free, no sign-up required, and your code stays in your browser.
Built by Florian Galz
Code minified? With fast web hosting, your site loads even faster.
Minified code
The minified code will appear here once you paste something on the left.Settings
Local variables and parameters get shorter names. Global names stay the same so other scripts can still find them.
Shortens expressions and removes dead code. The code's behavior stays the same.
Comments containing /*! … */, @license or @preserve are preserved.
Paste your code on the left or load the example. The result appears instantly.
Your code stays in your browser: it is neither uploaded nor saved.
Example result
What the JavaScript Minifier does to your code
You paste in readable JavaScript code. The tool removes comments and whitespace, shortens local names, and outputs the code as a compact line, along with its size before and after. The values below are a fixed example; your result depends on your code.
Example · Default settings
Input (readable)
// Warenkorb-Summe berechnenfunction calculateTotal(items, taxRate) { let subtotal = 0; for (const item of items) { subtotal += item.price * item.quantity; } const tax = subtotal * taxRate; return Math.round((subtotal + tax) * 100) / 100;} console.log(calculateTotal([{ price: 4.99, quantity: 2 }], 0.19));Output (minified)
function calculateTotal(t,o){let c=0;for(const o of t)c+=o.price*o.quantity;const a=c*o;return Math.round(100*(c+a))/100}console.log(calculateTotal([{price:4.99,quantity:2}],.19));- Original
- 324 B
- Minified
- 180 B
- Savings
- 44.4 %
- In this example, this much of the file consisted of comments, indentation, and long names.
Features
Smaller files, same functionality
What the minifier removes and what it deliberately keeps.
JavaScript with terser
Removes comments and whitespace, shortens local names, and simplifies expressions. Global names stay unchanged, and ES modules are detected.
CSS without surprises
Comments, whitespace, and trailing semicolons are removed. Values, colors, units, strings, and url() stay exactly the same.
HTML with inline code
Whitespace next to block elements is removed; a single space remains between words. style, script, and JSON-LD are minified too.
Size before and after
Savings in percent and bytes, plus both sizes with gzip, as transmitted by a web server.
Keep license comments
Comments marked with /*! … */, @license, or @preserve can be kept; conditional HTML comments are always kept.
Stays in your browser
No uploads or storage: the code is minified directly on your device.
How it works
How to minify JavaScript, CSS, and HTML online
Four steps, no sign-up or installation required.
Step 1
Choose a language
Select JavaScript, CSS, or HTML above. Each language retains its code when you switch.
Step 2
Paste code
Paste your code into the left field, open a file up to 2 MB, or load the example. The result appears on the right after a short pause in typing.
Step 3
Check settings
For JavaScript, you choose whether to shorten names and optimize expressions. You can keep license comments and, for HTML, regular comments too.
Step 4
Apply result
Check the savings with and without gzip, copy the minified code, or download it as script.min.js, style.min.css, or index.min.html.
Discover more
More tools
Compare text online (Diff Checker)
Compare text online: Compare two texts, configs, or code versions, see differences line by line and word by word, and copy them as a Unified Diff. Runs entirely in your browser.
Built by Dimitri Heissler
JSON Formatter
Format, minify, and validate JSON with syntax highlighting, error messages, and downloads, entirely in your browser.
Built by Jakub Martyniak
Regex Tester
Test regular expressions live against the native JavaScript engine—with match highlighting, capture groups, and replace mode, all in your browser.
Built by Jakub Martyniak
XML Formatter & Validator
Validate, format, minify, and automatically repair XML (unescaped characters, missing tags, missing declaration)—100% in your browser, without uploading.
Built by Justin Schuessler
Base64 Encoder/Decoder
Encode and decode text in Base64, including a URL-safe variant and clear error messages, entirely in your browser.
Built by Jakub Martyniak
.htaccess Generator & htpasswd Generator
Create Apache .htaccess and .htpasswd files online: 301 redirects, HTTPS, password protection with bcrypt, WordPress rules, error pages, caching, GZIP, and hotlink protection. Runs entirely in your browser.
Built by Dimitri Heissler
SQL Formatter Online (Format & Beautify SQL)
Format, beautify, and minify SQL online for MySQL, MariaDB, and PostgreSQL, with indentation and keyword casing. Runs entirely in your browser, with no uploads.
Built by Luca Stanek
HTML & CSS Formatter online (beautify your code)
Format, indent, and beautify HTML and CSS online with automatic language detection. Runs entirely in your browser, with no uploads.
Built by Luca Stanek
Compress & resize images
Compress and resize images online: reduce JPG, PNG, and WebP file sizes, set a target size in KB, or convert formats, such as PNG to JPG. Runs entirely in your browser.
Built by Dimitri Heissler
FAQ
Frequently asked questions
Quick answers about minifying JavaScript, CSS, and HTML with this tool.
The minified code and its size before and after. For example, the JavaScript sample on this page shrinks from 324 B to 180 B. You also see how large both versions would be with gzip compression, as delivered by a web server.
A minifier makes code smaller without changing how it works. It removes comments, indentation, and line breaks and shortens local variable names, so the file loads faster. This minifier handles JavaScript, CSS, and HTML.
Select the CSS tab and paste in your stylesheet. The tool removes comments, unnecessary whitespace, and the final semicolon in each block. Values, colors, and units stay exactly as you wrote them. You can choose to keep comments marked with /*! … */.
Select the HTML tab. Comments are removed, whitespace next to block elements such as div or p is removed, and whitespace between words and inline elements is reduced to one space so the page looks the same. pre and textarea stay unchanged. You can also choose to minify CSS in style and JavaScript in script.
No. The tool uses terser, the same minifier used by many build tools. It only shortens local names; global names stay unchanged so other scripts can still find them. In ES modules with import or export, top-level names are shortened too. If you turn off code optimization, names are only shortened; nothing is rewritten.
If JavaScript contains a syntax error or an unterminated comment or string, or HTML contains an unclosed tag, the tool shows its line and column. Click to jump to that position in the input. If a style or script block in HTML contains an error, the block is left unchanged and the tool lets you know.
Yes, they complement each other: gzip compresses repeated content, while minification removes comments and shortens names that gzip cannot eliminate. The tool shows you both sizes with gzip, so you can see how much of your code is actually transmitted.
No. Everything runs in your browser, with no uploads or storage. You can open files up to 2 MB, such as .js, .css, or .html.
Any more questions?
Contact SupportYour website needs fast hosting
Minified JavaScript, CSS, or HTML plus ZAP-Hosting web hosting: your site loads in no time. A VPS gives you more control.
No setup. No risk. Online in seconds.
Looking for more tools? View all developer tools
