Code Minifier
Code Minifier makes JavaScript, CSS, HTML and JSON smaller for developers and website owners. Process up to 2 MB in your browser, see the size saved, then copy or download the result.
What is the Code Minifier?
Code Minifier is a free browser tool that reduces the size of JavaScript, CSS, HTML and JSON snippets or file contents. Choose a language, paste your code and minify it locally without uploading it. JavaScript uses the open source Terser library to remove unnecessary characters, simplify code and optionally shorten local names. CSS and HTML use careful whitespace and comment removal, while JSON is parsed and written on one line. Developers, students and website owners can use it for quick checks or preparing small files. The result includes before-and-after sizes and the percentage saved.
Who it is for: Code Minifier is for frontend developers, students, freelancers, website owners and CMS editors working with code snippets.
How to use the Code Minifier
- Choose JavaScript, CSS, HTML or JSON under Language.
- Paste your source into Your code, or use Try with sample data for a quick test.
- For JavaScript, leave Shorten variable names inside functions on for smaller output or turn it off to retain local names; for HTML, leave Remove spaces between tags off unless you have checked inline spacing.
- Tap Minify, then review Minified code and the size comparison.
- Tap Copy result or Download, and test the output before replacing any deployed code.
Why use it
- Four languages in one placeChoose JavaScript, CSS, HTML or JSON without switching tools.
- See the actual savingCompare the size before and after minifying, with the percentage saved shown beside the result.
- Keep code on your deviceProcessing runs in your browser, so your source code is never uploaded.
- Take the result with youUse Copy result or Download to move the minified code into your project.
At a glance
- What you put in
- JavaScript, CSS, HTML or JSON pasted as text
- What you get
- Minified code, before-and-after sizes and percentage saved
- Limits
- Up to 2 MB; no TypeScript or JSX
- Privacy
- Runs in your browser. Nothing you enter is uploaded or stored.
- Price
- Free for everyone. No subscriptions, no payments, no watermark.
- Works offline
- Yes, once the page has loaded
- Last checked
- by AK Shine
Worked example
function add(first, second) { return first + second; }function add(n,d){return n+d}With JavaScript selected and local-name shortening on, this ASCII example shrinks from 54 bytes to 29 bytes, saving 25 bytes.
When to use something else
- Use a project build tool for TypeScript, JSX, bundling or repeatable production builds; this tool accepts up to 2 MB at a time.
- CSS and HTML minification here is careful rather than aggressive; dedicated build tools may reduce the output further.
- Keep your original file and test the result, especially when shortening JavaScript names or removing spaces between HTML tags.
Questions people ask
Can I minify JavaScript, CSS, HTML and JSON here?
Yes. Choose the matching format under Language, paste it into Your code and press Minify. JSON is parsed and written on one line; selecting HTML does not minify the contents of embedded script or style blocks.
Does minifying JavaScript change variable names?
The Shorten variable names inside functions switch is on by default and lets Terser shorten local names. Turn it off if you need to retain those names. JavaScript comments starting with ! or containing @license are kept.
Will HTML minification remove spaces between links?
It can if you enable Remove spaces between tags, which is off by default because it can close gaps between inline items. HTML mode removes comments and squeezes whitespace, but leaves pre, textarea, script and style blocks exactly as they are.
How does CSS minification handle URLs and quoted text?
CSS mode removes comments and spare whitespace while leaving text in quotes and url() untouched. It is deliberately conservative, so test the resulting stylesheet rather than assuming every possible size reduction has been made.
Why does my code show an error instead of a result?
Invalid JavaScript or JSON produces an error with the line so you can locate the problem in Your code. Correct the source and press Minify again. Inputs must be within 2 MB, and TypeScript and JSX are not supported.
Is Code Minifier free, private and available offline?
It is free with no subscriptions, and your code is processed in your browser without being uploaded. Once you have opened the tool, it also works offline.
Can minifying code break my website?
Minification aims to preserve behavior, but code that depends on particular JavaScript names or HTML spacing needs extra care. Test the output before deployment and keep your readable original, since minified code is harder to edit.
Is minification the same as Gzip or Brotli compression?
No. Minification changes the source text, while Gzip and Brotli compress data during delivery from a server. You can use both, but this tool does not configure transfer compression or guarantee a particular speed improvement.