Code minifier
Smaller files load faster — and on Indian mobile networks every kilobyte counts. This code minifiercompresses CSS, HTML and JavaScript by removing comments, indentation and unnecessary whitespace, and shows exactly how many bytes and what percentage you saved. CSS gets extra tidying (like dropping the last semicolon and the units on zero values), HTML keeps <pre> and inline scripts intact, and the JavaScript mode is deliberately safe: it never renames or rewrites your code.
How to use it
- Choose CSS, HTML or JavaScript.
- Paste your code — the minified version appears instantly.
- Copy or download it.
Example
The sample CSS shrinks from several indented lines with a comment to a single line like.btn{padding:0 16px;margin:0} — typically 30–50% smaller. Tidy JSON separately with theJSON formatter (its Minify option), or compare before and after withtext compare.
Frequently asked questions
What does minifying code do?
It removes things browsers don’t need — comments, indentation, extra spaces and line breaks — so files are smaller and pages load faster, especially on mobile data. The code works exactly the same.
Is the JavaScript minifier safe?
Yes — it’s deliberately conservative. It removes comments, indentation and blank lines but keeps line breaks and never renames variables, so automatic semicolon insertion and your logic are untouched. Strings, template literals and regular expressions are preserved exactly.
Why is my JS not as small as with a build tool?
Build tools like esbuild or Terser also rename variables and rewrite code, which gives smaller files but needs a full JavaScript parser. For production sites use those; this tool is for quick, safe cleanups and snippets.
Does HTML minification break <pre> blocks?
No. The contents of <pre>, <textarea>, <script> and <style> tags are kept exactly as they are; only the whitespace between other tags and HTML comments are removed.