Key Features of This JavaScript Minifier
- Instant, in-browser JS compression (no file uploads to servers)
- Removes comments and collapses unnecessary whitespace/newlines
- AST-based compression similar to Terser (constant folding, dead-code removal under safe conditions)
- Optional identifier mangling and advanced flags via API or build integration
- Works with modern JavaScript (ES2015+), classic scripts and simple module output
- One-click copy or download of the minified JavaScript
- Uses the same core component as the JavaScript formatter: switch between formatted and minified output with one action
- 100% client-side processing for maximum privacy
🛠️ How to Minify JavaScript for javascript-minifier
Paste or Upload Your JS
Drop a .js/.mjs file into the editor or paste your JavaScript directly. The tool is ideal for single scripts, utility files, and small bundles.
Choose Minification Mode
Use the same component as the JavaScript formatter: switch to the Minify action to get compressed output instead of formatted code.
Run the Minifier
Your code is parsed into an AST, comments and extra whitespace are stripped, and safe compression passes are applied to reduce bundle size.
Copy or Download the Result
Copy the minified JavaScript from the output editor or download it as a .min.js file and include it in your HTML, CDN or build output.
Technical Specifications
Core Transformations (Safe Defaults)
Conservative defaults are designed to preserve runtime behavior while significantly shrinking code size.
| Operation | Applied | Notes |
|---|---|---|
| Remove line and block comments | ✅ | License comments (/*! ... */) can be preserved via configuration/API |
| Collapse whitespace and newlines | ✅ | Whitespace normalized where semantically safe; string and regex contents preserved |
| Constant folding and simple inlining | ✅ | Only when the result is provably equivalent |
| Dead-code elimination | ✅ | Removes branches that are unreachable after constant propagation |
| Identifier mangling | ✅ Optional | Shortens variable and function names; configurable via advanced options/API |
| Drop debugging helpers (console/debugger) | ✅ Optional | Can be enabled when you do not rely on console output in production |
Safety & Compatibility Controls
Advanced options (exposed mainly via build tools/API) help tune how aggressive minification should be.
| Option | Default | Explanation |
|---|---|---|
| ecma target | 2020 | Controls output syntax and some compress rules |
| module vs script | script | Enable module/toplevel optimizations for ESM bundles |
| keep_fnames / keep_classnames | false | Preserve names for better stack traces or DI frameworks |
| safari10 / legacy quirks | off | Enable only when targeting specific legacy engines |
| toplevel | false | Allows dropping unused top-level bindings for advanced tree-shaking |
Typical Size Reduction
Savings vary depending on original formatting, comment density, and how much dead code exists.
| Input Style | Compress Only | Compress + Mangle (Aggressive) |
|---|---|---|
| Heavily commented and spaced | 35%–55% | 50%–70% |
| Moderately formatted application code | 20%–35% | 35%–55% |
| Already compact code | 5%–15% | 10%–25% |
CLI Alternatives for Production Builds
For full applications and multi-file projects, integrate minification into your CI/CD pipeline.
Node.js
Terser (common case)
npx terser src/app.js -o dist/app.min.js -c ecma=2020,passes=2 -mTwo compress passes plus identifier mangling for strong size reduction.
Terser with reserved names and drop_console
npx terser src/app.js -o dist/app.min.js -c passes=2,drop_console=true -m reserved=["React","ReactDOM"] --keep-fnamesProtect important globals, remove console calls, and keep function names for debugging.
Linux/macOS/Windows
esbuild (very fast)
npx esbuild src/app.js --minify --target=es2018 --outfile=dist/app.min.jsBundle and minify in a single, extremely fast step.
SWC (Rust-based)
npx swc src -d dist --minifyTranspile and minify with a high-performance Rust engine.
Common Use Cases
Web Performance & Core Web Vitals
- Reduce JavaScript transfer size for faster LCP and TTI
- Trim debug comments and logging before deployment
- Shrink client-side bundles before gzip/brotli compression
/* build-only comment that will be stripped in minified output */CI/CD and Release Automation
- Minify JS as a final step in your build pipeline
- Prepare small, cache-friendly bundles for CDNs
- Generate production-ready assets alongside HTML/CSS minifiers
Widgets, Embeds & Experiments
- Ship compact snippets via tag managers
- Embed minified widgets in third-party pages
- Experiment with different compress strategies on critical scripts
❓ Frequently Asked Questions
Will minifying JavaScript change how my code runs?
Does this tool handle TypeScript or JSX directly?
Is my JavaScript uploaded to a server?
How big can my JavaScript file be?
What is the difference between formatting and minifying?
Pro Tips
Define NODE_ENV=production (or equivalent) in your bundler to unlock additional dead-code pruning in many libraries.
Keep unminified sources (and, for large apps, source maps) in version control, and serve only minified assets in production.
Use reserved names when mangling to protect public APIs hanging off window or globalThis.
Combine minification with gzip or brotli at the CDN or server level to get multiplicative size savings.
Additional Resources
Other Tools
- CSS Beautifier
- HTML Beautifier
- Javascript Beautifier
- PHP Beautifier
- Color Picker
- Sprite Extractor
- Base64 Decoder
- Base64 Encoder
- Csharp Formatter
- Csv Formatter
- Dockerfile Formatter
- Elm Formatter
- ENV Formatter
- Go Formatter
- Graphql Formatter
- Hcl Formatter
- INI Formatter
- JSON Formatter
- Latex Formatter
- Markdown Formatter
- Objectivec Formatter
- Php Formatter
- Proto Formatter
- Python Formatter
- Ruby Formatter
- Rust Formatter
- Scala Formatter
- Shell Script Formatter
- SQL Formatter
- SVG Formatter
- Swift Formatter
- TOML Formatter
- Typescript Formatter
- XML Formatter
- YAML Formatter
- Yarn Formatter
- CSS Minifier
- Html Minifier
- JSON Minifier
- XML Minifier
- Http Headers Viewer
- PDF To Text
- Regex Tester
- Serp Rank Checker
- Whois Lookup