stakritools
Developer
  • Base64 Encoder/Decoder
  • Color Picker & Converter
  • CSS Minifier
  • CSV to JSON Converter
  • Hash Generator
  • HTML Minifier
  • JS Minifier
  • JSON Formatter & Validator
  • JSON to CSV Converter
  • JWT Decoder
  • Markdown Editor
  • Password Generator
  • Regex Tester
  • SQL Formatter
  • Unix Timestamp Converter
  • URL Encoder/Decoder
  • UUID Generator
  • XML Formatter
  • YAML Formatter
View all
Image
  • Favicon Generator
  • Image Compressor
  • Image Cropper
  • Image Flipper
  • Image Resizer
  • Image Rotator
  • Image to Base64
  • JPG to PNG Converter
  • PNG to JPG Converter
  • QR Code Generator
  • SVG to PNG Converter
  • Watermark Image
  • WebP Converter
View all
SEO
  • FAQ Schema Generator
  • Meta Description Generator
  • Open Graph Generator
  • Robots.txt Generator
  • SEO Site Auditor
  • SERP Preview
  • Slug Generator
  • Twitter Card Generator
View all
Text
  • Case Converter
  • Find and Replace
  • Lorem Ipsum Generator
  • Random Text Generator
  • Remove Duplicate Lines
  • Remove Extra Spaces
  • Text Diff Checker
  • Word Counter
View all
Calculator
  • Age Calculator
  • BMI Calculator
  • Compound Interest Calculator
  • Date Difference Calculator
  • Discount Calculator
  • EMI Calculator
  • GST Calculator
  • Income Tax Calculator
  • Loan Calculator
  • Percentage Calculator
  • SIP Calculator
  • Tip Calculator
  • Unit Converter
View all
Blog
stakritools

205+ free, browser-based tools for developers, marketers, and creators — no sign-up, no clutter.

Developer Tools

  • Base64 Encoder/Decoder
  • Color Picker & Converter
  • CSS Minifier
  • CSV to JSON Converter
  • Hash Generator
  • HTML Minifier
  • JS Minifier
  • JSON Formatter & Validator
  • JSON to CSV Converter
  • JWT Decoder
  • Markdown Editor
  • Password Generator
  • Regex Tester
  • SQL Formatter
  • Unix Timestamp Converter
  • URL Encoder/Decoder
  • UUID Generator
  • XML Formatter
  • YAML Formatter

Image Tools

  • Favicon Generator
  • Image Compressor
  • Image Cropper
  • Image Flipper
  • Image Resizer
  • Image Rotator
  • Image to Base64
  • JPG to PNG Converter
  • PNG to JPG Converter
  • QR Code Generator
  • SVG to PNG Converter
  • Watermark Image
  • WebP Converter

SEO Tools

  • FAQ Schema Generator
  • Meta Description Generator
  • Open Graph Generator
  • Robots.txt Generator
  • SEO Site Auditor
  • SERP Preview
  • Slug Generator
  • Twitter Card Generator

Text Tools

  • Case Converter
  • Find and Replace
  • Lorem Ipsum Generator
  • Random Text Generator
  • Remove Duplicate Lines
  • Remove Extra Spaces
  • Text Diff Checker
  • Word Counter

Calculator Tools

  • Age Calculator
  • BMI Calculator
  • Compound Interest Calculator
  • Date Difference Calculator
  • Discount Calculator
  • EMI Calculator
  • GST Calculator
  • Income Tax Calculator
  • Loan Calculator
  • Percentage Calculator
  • SIP Calculator
  • Tip Calculator
  • Unit Converter

Company

  • Blog
  • About
  • Privacy Policy
  • Contact
© 2026 stakritools. All rights reserved.
  1. Home
  2. Developer
  3. JS Minifier
Developer

JS Minifier

Minify JavaScript to shrink file size for production using Terser — the same minifier used by major bundlers. See original size, minified size, and exact savings, all computed in your browser.

Try:

How To Use

  1. 1.Paste or type your raw JavaScript into the input box — the tool minifies it live as you type, with no button to click.
  2. 2.The minifier compresses your code (removing dead code, simplifying expressions), mangles variable names to short identifiers, and strips comments and whitespace.
  3. 3.Check the stats bar to see the original size, the minified size, and the exact percentage saved.
  4. 4.If your code has a syntax error, a clear message tells you what's wrong instead of a silent failure, so you can fix it and try again.
  5. 5.Load one of the Try examples to see a function with comments, verbose variable names, and dead code minified in real time.
  6. 6.Copy the minified result, download it as a .js file, or share a link to this tool once you're done.

Examples

Commented function
A short commented function with a verbose variable name — shows comment stripping and variable mangling.
Dead code
An unreachable branch and an unused variable, demonstrating Terser's dead-code elimination.
Arrow functions & template literals
Modern ES6+ syntax with arrow functions and template literals, confirming full support.
Class with methods
An ES6 class with a constructor and method, showing class syntax passes through minification correctly.

About JS Minifier

Why Minify JavaScript?

JavaScript is frequently the largest asset type on a modern web page, and unlike CSS, it isn't just downloaded — the browser also has to parse and compile it before any of it can run, and in many cases execute it before the page becomes interactive. Every byte removed from a JavaScript bundle reduces all three of these costs: download time, parse and compile time, and often first-load execution time, making minification one of the highest-leverage, lowest-effort performance optimizations available for any JavaScript-heavy site or application.

Beyond raw whitespace and comment removal, a proper minifier like Terser performs genuine code transformations that a human wouldn't reasonably apply by hand across an entire codebase: eliminating unreachable code, shortening variable names throughout every scope, simplifying boolean and arithmetic expressions, and inlining variables that are only referenced once. On a real production bundle, these combined optimizations routinely cut file size by 30-70% depending on how verbosely the original source was written, which translates directly into faster page loads — especially significant for users on slower connections or lower-powered devices, where JavaScript parse and execution time can dominate total load time even more than the download itself.

How JavaScript Minification Works

A real JavaScript minifier doesn't operate on raw text — it fully parses your source code into an Abstract Syntax Tree (AST), the same structured, hierarchical representation of your program's actual logic that a JavaScript engine itself builds before executing your code. Working from this AST rather than from text is what makes safe, aggressive minification possible: the minifier can prove that a particular variable is only ever referenced within a specific scope, or that a branch can never be reached given a constant condition, in a way that a naive text-based find-and-replace tool never could.

From this parsed representation, Terser applies its transformations in stages: a compression pass that simplifies and shortens equivalent code (removing dead branches, folding constant expressions, collapsing sequential statements), a mangling pass that renames every local variable and function parameter to the shortest available identifier while carefully preserving anything that must keep its original name (globals, exported names, property keys accessed dynamically), and finally a code-generation pass that serializes the optimized AST back into JavaScript text using the most compact valid syntax — omitting unnecessary semicolons, parentheses, and whitespace wherever the grammar allows it.

Minification vs Bundling vs Transpilation

These three build steps are often applied together in a modern JavaScript build pipeline but each solves a genuinely distinct problem, and it's worth understanding the difference. Bundling (done by tools like Webpack, Rollup, or esbuild) combines many separate source files and their dependencies into one or a few output files, reducing the number of separate network requests a browser needs to make to load your application. Transpilation (done by Babel or a similar tool) rewrites modern JavaScript syntax into an older, more widely-supported syntax so your code runs correctly on browsers that don't yet support newer language features — this is a correctness and compatibility concern, not a size concern.

Minification, the step this tool performs, comes after bundling and transpilation in a typical pipeline and focuses purely on making the final, already-combined, already-compatible code as small as possible without changing its behavior. A production build pipeline typically runs all three in sequence — transpile for compatibility, bundle for fewer requests, then minify for smaller size — and it's worth minifying last, since minifying before bundling or transpiling can interfere with those later steps' ability to analyze and transform your code correctly.

JavaScript Minification Best Practices

Always keep your original, readable, well-commented source code as the single source of truth in version control, and treat minified output as a disposable, regenerable build artifact — never hand-edit minified code directly, since any change would be silently lost the next time your build pipeline regenerates it from source. In a real project, minification should be an automated part of your production build step, paired with source map generation, so that error monitoring tools and browser DevTools can map a minified stack trace back to the original, readable source line when something goes wrong in production — without source maps, debugging a live issue in minified code becomes dramatically harder.

Double-check any code that relies on a function or class's .name property, or on Function.prototype.toString() output, for actual runtime logic (rather than pure debugging/logging) before minifying it, since mangling is specifically designed to change those names and can break logic that secretly depends on them. Finally, remember that minification and compression (gzip or Brotli, applied by your web server) are complementary, not redundant — minification reduces the raw byte count before compression even runs, and compression then squeezes further redundancy out of the minified result, so a production deployment benefits from doing both rather than treating either as sufficient on its own.

FAQs

No. Minification runs entirely inside your browser using Terser, a JavaScript minifier written in JavaScript itself, compiled to run client-side — there is no server-side component involved in processing your code at any point. This means you can safely paste proprietary application logic, internal utility functions, or unreleased feature code into this tool without it ever leaving your device or being logged anywhere. You can confirm this yourself by opening your browser's developer tools and watching the network tab while you use the tool — you won't see any outgoing requests carrying your code. Even if your internet connection drops after the page has finished loading, the minifier keeps working exactly the same, since it has no dependency on a live server connection to function.

Terser is a widely used, actively maintained JavaScript parser, mangler, and compressor toolkit — it's a maintained fork of the older UglifyJS project, created specifically to add proper support for modern ES6+ syntax (arrow functions, classes, destructuring, async/await) that UglifyJS's original parser couldn't handle. Terser is the minifier bundled by default inside Webpack, Vite's production builds, and Rollup's terser plugin, which means the exact same minification engine powering this tool is the one that actually processes the JavaScript shipped by an enormous share of real-world production websites — it's a mature, extensively tested piece of infrastructure, not an experimental or hand-rolled minifier.

Minification applies three broad categories of transformation. Compression rewrites your code into a logically equivalent but more compact form — removing dead code that can never execute, simplifying conditional expressions, inlining single-use variables, and shortening equivalent syntax patterns. Mangling renames local variables and function parameters to short, meaningless identifiers (a becomes a single letter, a longer name becomes a shorter one) wherever it's provably safe to do so, since the JavaScript engine executing your code doesn't care what a variable is named, only what it refers to. Whitespace and comment removal strips everything that exists purely for human readability — indentation, line breaks, and comments — none of which affects how the code actually runs.

Terser is designed to produce output that behaves identically to your original code in every case it can prove is safe, and it has been battle-tested against millions of real-world production codebases as the default minifier in major build tools — genuine minifier bugs on valid, standard JavaScript are rare. That said, a small number of code patterns are legitimately unsafe to minify automatically, most notably relying on a specific function's name string at runtime (via .name or Function.prototype.toString()) for logic rather than debugging, or code that depends on Function constructor behavior with dynamically-referenced variable names — these patterns break under variable mangling because the whole point of mangling is renaming things, and Terser has no way to know your runtime logic secretly depends on a specific original name. If minified output behaves differently from the original, this dependency on names is the first thing to check.

The stats bar shows the byte size of your input code exactly as typed or pasted, the byte size of the minified output, and the percentage difference between them. This reflects the actual reduction in bytes a browser has to download and parse — a meaningful, direct measure of the network and parse-time cost you're removing from a real production deployment. Keep in mind that gzip or Brotli compression (which virtually every production web server applies on top of minification) tends to shrink minified JavaScript further still and often narrows the gap between minified and unminified compressed sizes, since repeated patterns compress well regardless of whether they're written out with long or short names — minification's biggest win is usually on uncompressed transfer size and parse/execution speed, not solely on the final gzipped byte count.

This is mangling working as intended — Terser renames local variables and function parameters to short identifiers like a, b, or e specifically because shorter names take fewer bytes to transmit and are marginally faster for a JavaScript engine to parse and intern. A JavaScript engine has no concept of a variable being 'meaningfully named'; it only cares about scope and reference identity, so renaming userAccountBalance to a changes absolutely nothing about how your program behaves, as long as every reference to that variable is consistently renamed together — which Terser guarantees by fully parsing your code into an abstract syntax tree rather than doing a blind text find-and-replace. If you need to debug minified code in production, pair it with a source map (which this simple browser tool doesn't generate, but your build pipeline's minification step typically can) to map minified names back to their original source location.

Yes — Terser fully supports modern ECMAScript syntax including arrow functions, template literals, destructuring, classes, async/await, generators, optional chaining (?.), and nullish coalescing (??), since supporting exactly this kind of modern syntax robustly was Terser's original reason for existing as a fork of the older, ES5-focused UglifyJS project. If you paste code using a very recent or still-experimental proposal-stage syntax feature that hasn't yet been finalized into the ECMAScript standard, it's possible the parser won't recognize it — in that case, you'll get a clear parse error rather than silently mangled or broken output.

For any real production project, your build tool (Webpack, Vite, esbuild, Rollup, or your framework's own build step) should minify JavaScript automatically as part of the production build — that's more reliable, integrates with source map generation for debugging, and ensures minification happens consistently on every deploy without a manual step anyone could forget. This tool is most useful for one-off tasks: minifying a single script you're about to paste somewhere without a build pipeline (a bookmarklet, an inline <script> tag, a browser extension content script, a CodePen), quickly checking how much a snippet could shrink, or understanding roughly what minification does to a piece of code you're curious about. It's a utility for ad hoc work, not a replacement for an automated, source-map-aware build process.

No, though they're often confused. Minification's goal is purely reducing file size while preserving behavior — it happens to make code harder to read as a side effect of shortening names and removing formatting, but that's not its primary purpose, and a motivated reader can still fairly easily deobfuscate and understand minified logic by reformatting it and tracing variable usage. True obfuscation is a separate, deliberate practice aimed specifically at making code difficult to understand or reverse-engineer — techniques like string encryption, control-flow flattening, and opaque predicates that Terser's mangler doesn't apply and isn't designed for. If your goal is genuinely protecting intellectual property from reverse engineering (rather than just reducing load time), you need a dedicated obfuscation tool, not a minifier — and it's worth knowing that even dedicated obfuscation only raises the difficulty of reverse engineering, it doesn't make client-side code secret, since the browser executing it always has access to the real logic at runtime.

The achievable savings from minification depend heavily on how the original code was already written. Code that already uses short variable names, has minimal comments, and is written compactly will show smaller percentage gains simply because there's less redundant human-readability overhead left to remove — there's a real floor below which minification can't shrink correctly-functioning code further. Code with long, descriptive variable names, generous comments, and verbose formatting (common and genuinely good practice for source code meant to be read and maintained by humans) tends to show much larger percentage savings, because more of its original size was purely for human benefit rather than something the JavaScript engine needed. A small percentage savings on already-terse code isn't a sign anything went wrong — it usually just means there wasn't much readability overhead to begin with.

Related Tools

JS Minifier optimizes script size for production. These related developer tools cover other performance and formatting tasks in the same front-end build workflow.

CSS Minifier
DeveloperMinify CSS with the same size-savings workflow, for the other major render-blocking asset type.
JSON Formatter & Validator
DeveloperFormat and validate JSON — handy for inspecting a config or data file referenced by your script.
Regex Tester
DeveloperTest a pattern for extracting or validating strings before wiring it into your JavaScript.
Base64 Encoder/Decoder
DeveloperEncode or decode Base64 strings, a common need when embedding small assets directly in JavaScript.