Free JavaScript Minifier
Minify JavaScript with browser-based compression. Strip whitespace and comments for smaller snippets. Free, no signup, instant.
What the JS Minifier does
JavaScript minification is essential for production. This tool removes comments and unnecessary whitespace so snippets are smaller and faster to transfer.
Paste, minify, copy, deploy after testing in your own project.
How to minify JavaScript
Five steps from paste to production.
Paste your JS code
Source code, one file at a time. Up to 5MB.
Click Minify
The tool removes comments and unnecessary whitespace.
Compare sizes
See original vs. minified. Confirm reduction is meaningful.
Copy output
One-click copy of the minified code.
Deploy to production
Replace original JS with minified version. Pair with gzip on server.
When developers use it
Six common workflows.
Pre-production deployment
Minify all JS before deploying to production. Smaller bundles = faster pages.
CDN script optimization
For CDN-hosted JS libraries, minify before upload to reduce bandwidth.
Email-embedded scripts
Some email tracking pixels include JS. Minify to fit under email-platform limits.
Static site asset optimization
Hugo, Jekyll, and other SSGs may not auto-minify; run JS through this tool.
Embed code generation
When generating embed widgets for users to install, minify before distribution.
Performance audit fixes
PageSpeed flagged unminified JS. Run through here for a quick fix.
Platform-specific setup guides
How to deploy minification on the platforms most teams use.
Webpack / Vite / Rollup
- These bundlers include Terser by default in production mode.
- Verify with `webpack --mode production` or `vite build`.
- Use this tool only for one-off snippets or non-bundled code.
WordPress
- Plugin like Autoptimize or W3 Total Cache handles JS minification.
- For custom JS in theme files, run through this tool first.
- Verify with PageSpeed.
Next.js
- Next.js minifies JS in production builds automatically (SWC or Terser).
- For custom <script> tags or external libs, minify yourself.
- Verify with build output.
Static sites
- Hugo, Jekyll, 11ty have plugins for JS asset processing.
- For external libs in /public/, minify before adding.
- Spot-check with this tool.
Email tracking pixels
- Run JS through this tool before embedding in email.
- Aim for under 1KB minified for tracking scripts.
- Test in major email clients (Gmail, Outlook).
Grigora vs. other JS minifiers
Side-by-side comparison.
| Capability | Grigora | Terser CLI | JSCompress | Free generators | Manual |
|---|---|---|---|---|---|
| Free + unlimited | Yes | Yes | Free trial | Yes | Manual |
| Browser-based minification | Yes | CLI | Yes | Various | Manual |
| ES2022/ES2024 support | Yes | Yes | Yes | Mixed | Manual |
| Strip console.log option | Yes | No | Yes | No | Manual |
| Privacy: no file retention | Yes | Stored | Stored | Mixed | Yes |
| No signup | Yes | Yes | Account required | Yes | Yes |
| Visual size comparison | Yes | Yes | Yes | No | Manual |
| Result speed | <3 sec | <5 sec | <3 sec | <5 sec | Manual |
Common errors and how to fix them
Eight issues developers hit when minifying JS.
Minified code throws a runtime error
Cause: Aggressive renaming broke a global reference.
Fix: Use Terser's reserved option to preserve specific names. Or use simpler minification settings.
Code uses eval()
Cause: Minification renames variables that eval references break.
Fix: Avoid eval. Or wrap in a try-catch with original code as fallback. Or skip minification.
Strict mode breaks after minification
Cause: Conflicting "use strict" directives or removed statements.
Fix: Add "use strict" at the top; ensure code is strict-mode compliant before minification.
Sourcemaps not generated
Cause: No sourcemap option configured.
Fix: Use Terser with sourceMap: true. Necessary for production debugging.
Tool fails on huge file
Cause: File over 5MB.
Fix: Split into modules; minify each separately.
TypeScript files not supported
Cause: Tool expects pure JS.
Fix: Compile TS to JS first via tsc or esbuild.
License comments removed
Cause: Default settings strip all comments.
Fix: Mark with /*! */ to preserve.
Output has extra semicolons
Cause: ASI (automatic semicolon insertion) was relied on.
Fix: Add explicit semicolons in source; minifier preserves them.
Original data from our 2026 minification audit
Across 5,000 minifications.
Frequently asked questions
Twelve answers about JavaScript minification.
Related free tools
Other utilities that pair with the JS Minifier.
CSS Minifier
Strip whitespace from CSS for production.
Try itHTML Minifier
Compress HTML pages and templates.
Try itHTML to Text Cleaner
Strip HTML to plain text.
Try itImage Compression Rating Tool
Score image compression A-F.
Try itImage Compressor
Compress images for page speed.
Try itPageSpeed Insights Analyzer
See the bigger Core Web Vitals picture.
Try it