JavaScript Code Compressor
Minify and compress your JavaScript code for better performance
Drop your JavaScript file here or click to browse
Supports .js files up to 10MB
Original Code
Compressed Code
Compression Settings
Compression Statistics
JavaScript Compressor & Minifier — Production-Ready JS in Seconds
Our free JavaScript compressor reduces file size by stripping everything a browser does not need: whitespace, indentation, comments, and unnecessary semicolons. The result is functionally identical JavaScript that downloads faster, parses faster, and executes with no change in behaviour. For large JS bundles, minification alone can reduce transfer size by 30–50% before gzip is applied.
JavaScript is typically the biggest performance bottleneck on modern websites. Unlike HTML and CSS, JavaScript blocks the main thread during parsing and execution. Smaller JS files unblock the main thread sooner, improving Time to Interactive (TTI) and First Input Delay — both Core Web Vitals signals that affect Google search rankings.
What Does JavaScript Minification Actually Do?
- Whitespace removal — spaces, tabs, and line breaks between tokens are eliminated
- Comment stripping — single-line (//) and multi-line (/* */) comments are removed
- Semicolon insertion — trailing semicolons before closing braces are dropped where valid
- Variable name shortening (Advanced mode) — local variables like longVariableName become a, b, c
- Dead code elimination (Advanced mode) — unreachable code and unused variables are removed
Basic vs Advanced Compression
Basic mode is safe for all JavaScript. It removes whitespace and comments only — structure and variable names are preserved. Use for: libraries with unusual syntax, legacy code, jQuery plugins, and any code not fully tested.
Advanced mode applies all Basic optimisations plus variable renaming, dead code removal, and property flattening. Typically achieves 40–60% size reduction. Use for: modern ES6+ code you control, after thorough staging testing. Always test before deploying to production.
How to Use This JS Compressor
- Paste or upload — paste JavaScript into the left editor, or drag and drop a .js file up to 10MB.
- Select compression level — Basic (safe) or Advanced (deeper, variable renaming).
- Click Compress JavaScript — minified output appears in the right panel with original size, compressed size, and percentage saved.
- Copy or download — copy to clipboard or download as a .min.js file ready to deploy.
Best Practices
- Never overwrite source files. Keep originals and name minified output app.min.js.
- Generate source maps. Source maps let DevTools map minified code back to original line numbers for debugging.
- Test Advanced mode on staging. Variable renaming can break code using eval(), dynamic property access, or certain serialization patterns.
- Combine with server compression. gzip or Brotli on top of minification can achieve 80–90% total transfer size reduction.
- Automate in your build pipeline. Use Terser (webpack), esbuild (Vite), or UglifyJS to minify on every build automatically.
- Use tree-shaking. Modern bundlers eliminate unused ES module exports. Combine with minification to ship only code users need.
Impact on Core Web Vitals
Lighthouse flags "Minify JavaScript" as a direct opportunity. Minifying your JS reduces download and parse time, which directly improves Largest Contentful Paint (LCP) and Time to Interactive (TTI). The audit flags savings over 2KB. Combined with gzip, jQuery's 272KB source becomes around 30KB transferred — an 89% reduction.
Frequently Asked Questions
Is JavaScript minification safe for my code?
Basic mode is safe for all JavaScript — it only removes whitespace and comments with no logic changes. Advanced mode should be tested on staging for code using eval(), dynamic imports, or unusual patterns.
What is the difference between Basic and Advanced compression?
Basic removes whitespace, comments, and redundant semicolons. Advanced additionally shortens variable names, removes dead code, and flattens expressions for significantly smaller output. Basic is recommended as the safe default.
What is the difference between minification and obfuscation?
Minification reduces file size by removing unnecessary characters. Obfuscation intentionally makes code hard to read. Advanced mode applies some name shortening which has a mild obfuscation effect, but this tool focuses on performance, not security.
Do you store my JavaScript code?
No. Code is processed server-side for the compressed output only. We do not store, log, or share your code. The temporary download file is automatically deleted.
Can I compress TypeScript files?
Compile TypeScript to JavaScript first using tsc or your build tool (Vite, webpack), then paste the compiled .js output here for minification.