Skip to main content

    JavaScript Minifier

    Minify JavaScript online, strip comments and whitespace to reduce bundle size.

    Free to use. Runs in your browser.

    Paste JavaScript and click Minify to shorten variable names, strip whitespace, and remove comments. Typical size reduction is 40 to 70%.

    Input JavaScript

    Minified Output

    Why Minify JavaScript?

    JavaScript is usually the biggest bottleneck in web performance. It has to be downloaded, parsed, compiled, and executed, all before your page becomes interactive. Every kilobyte counts. Minification strips the parts humans need (comments, whitespace, readable names) while keeping everything the browser needs.

    A typical JavaScript file shrinks 30-60% after minification. That's not just faster downloads, it's faster parsing too. V8 (Chrome's JS engine) parses minified code faster because there's less text to process. For mobile users on slow connections, the difference between 200KB and 100KB of JS can mean seconds of load time.

    This tool handles comment removal, whitespace collapsing, and basic operator spacing. For production use, build tools like Terser, esbuild, or SWC provide advanced optimisations like dead code elimination, tree shaking, and variable mangling.

    What Minification Removes

    ElementBeforeAfterSavings
    Comments// Calculate total /* Multi-line */(removed)10-30% of file typically
    WhitespaceIndentation, blank linesCollapsed to minimum15-25% of file
    Line breaksOne statement per lineEverything on fewer lines5-10% of file
    Variable names*calculateTotalPriceaSignificant for large files
    Dead code*Unreachable branches(removed)Varies widely

    What this means for you: Items marked with * require advanced AST-based minifiers (Terser, esbuild). This online tool handles comments and whitespace, the quick wins that don't risk changing behaviour. Use it for one-off jobs; use build tools for production.

    JavaScript Minifier Comparison

    ToolSpeedCompressionBest For
    TerserModerateExcellent (AST-based)Webpack/Vite production builds
    esbuildVery fast (Go)Very goodSpeed-critical CI/CD pipelines
    SWCVery fast (Rust)Very goodNext.js, modern frameworks
    UglifyJSSlowGood (ES5 only)Legacy projects
    Google ClosureSlowBest (advanced mode)Maximum compression, type-aware

    Real-World Size Savings

    LibraryOriginalMinifiedMinified + Gzip
    jQuery 3.7282 KB87 KB (69%)30 KB
    React 18140 KB45 KB (68%)14 KB
    Lodash544 KB71 KB (87%)25 KB
    Three.js1.2 MB650 KB (46%)170 KB
    Typical app bundle500 KB200 KB (60%)65 KB

    Minification alone cuts 50-70%. Add Gzip/Brotli compression (which your server should already enable) and you're typically looking at 85-90% total reduction. That 500 KB bundle becomes 65 KB over the wire.

    Related Tools

    How to use this tool

    1

    Paste your JavaScript into the input area

    2

    Click Minify JavaScript to compress

    3

    Copy the result or download as a .min.js file

    Common uses

    • Reducing JavaScript file size for production
    • Stripping comments from code before deployment
    • Quick minification for inline scripts
    • Comparing file sizes before and after compression

    Share this tool

    Frequently Asked Questions

    What does JavaScript minification do?
    It removes comments, whitespace, line breaks, and unnecessary characters from your JavaScript code. The result is functionally identical code that's 30-60% smaller. Smaller files download faster, parse faster, and reduce bandwidth costs.
    Will minification break my code?
    Basic minification (comments and whitespace removal) is safe. Advanced minification (variable renaming, dead code removal) requires AST-based tools and proper testing. This tool handles the safe basics, use Terser or esbuild for production builds.
    Is my code sent to a server?
    No. All minification happens in your browser using JavaScript regex operations. Nothing is uploaded, stored, or transmitted. Safe for proprietary code.
    How much will my file shrink?
    Typically 30-60% depending on how much whitespace and comments your code contains. Well-commented code with generous formatting saves more. Already-compact code saves less. The tool shows exact before/after byte sizes.
    Should I minify in development?
    No, work with readable code during development. Only minify for production. Your build tool (Vite, webpack, esbuild) should handle minification automatically as part of the production build. Source maps let you debug production code in its readable form.
    What's the difference between minification and bundling?
    Minification shrinks individual files. Bundling combines multiple files into one (fewer HTTP requests). Tree shaking removes unused exports. Modern build tools do all three. This tool only does minification, for the full pipeline, use a build tool.
    What about source maps?
    Source maps connect minified code back to the original source for debugging. They're generated by build tools alongside the minified output. This online tool doesn't generate source maps, it's for quick one-off minification, not production pipelines.
    Does minification affect SEO?
    Indirectly, yes. Google uses page load speed as a ranking factor via Core Web Vitals. Smaller JavaScript files mean faster Time to Interactive (TTI) and lower Total Blocking Time (TBT). For content-heavy pages, reducing JS size directly improves SEO metrics.
    What's Terser and why should I use it?
    Terser is the industry-standard JavaScript minifier used by Vite and webpack. It parses your code into an Abstract Syntax Tree (AST), then rewrites it optimally, renaming variables, removing dead code, and simplifying expressions. Much more powerful than regex-based approaches.
    Can I minify ES6+ and TypeScript?
    This tool handles JavaScript syntax. TypeScript needs to be compiled to JavaScript first. For ES6+ features like arrow functions and template literals, the tool preserves them. Terser and esbuild handle all modern syntax natively.
    What's the difference between Terser and esbuild?
    Terser is written in JavaScript, slower but produces slightly smaller output. esbuild is written in Go, 10-100x faster but slightly less aggressive compression. For most projects, esbuild's speed advantage outweighs the 1-2% size difference.
    How do I minify automatically in my build?
    Vite uses esbuild for minification by default. Webpack uses Terser via TerserPlugin. Next.js handles it automatically. Most modern frameworks minify JavaScript as part of their production build with zero configuration needed.

    Results are for general informational purposes only and should be checked before use. They are not professional advice. See our Disclaimer and Terms of Service.