Home / Tools / JavaScript minifier

JavaScript Minifier: Compress JS and Reduce File Size Online

Compress JavaScript by removing comments and whitespace, and optionally renaming local variables to short names. Shows the bytes saved. Runs in your browser.

Paste your JavaScript and press Minify. Comments and extra whitespace are removed, and the page shows the size before and after. Tick Rename local variables to shorten function parameters and variables too. The renamer is careful: it leaves global names, object properties and anything it cannot prove safe alone.

What it does

The renamer changes the names of local variables, so function.name values inside functions and stack traces will show short names. Test your code after minifying, as with any minifier. It does not remove dead code or rewrite expressions like Terser does.

Example

Before

// add two numbers
function add(a,b){const total=a+b;if(total>10){console.log("big")}return total}
const items=[1,2,3].map(n=>add(n,2));

After

function add(a,b){const total=a+b;if(total>10){console.log("big")}return total}
const items=[1,2,3].map(n=>add(n,2));

Frequently asked questions

Is this as small as Terser or esbuild?
Not quite. With renaming on, local names shrink like in those tools, but it does not remove dead code, inline functions or rewrite expressions. For production builds, use a build tool; for quick jobs and snippets this gets most of the saving.
What does Rename local variables change?
Only names that live inside functions: parameters, var, let, const, inner functions and classes. Names at the top level of your script stay as they are, because other scripts and your HTML may use them. Property names (obj.name) are never changed.
When does it skip renaming?
If the code calls eval(), uses a with statement, contains JSX, TypeScript or type annotations, or has a syntax error, the page tells you why and still removes comments and whitespace.
Will it break my code?
The renamer is checked by running real programs before and after renaming and comparing the results. Even so, test minified code. Code that depends on function names or reads its own source with toString() can behave differently.
Can it handle modern JavaScript?
Yes: arrow functions, classes, destructuring, template literals, optional chaining, generators and async code.
Does it keep license comments?
Tick the option to keep comments that start with /*!

Runs in your browser. Nothing you type is sent to this site. Updated 2026-10-11.

More tools

Code formatters

CSS beautifier CSS minifier HTML beautifier HTML minifier JavaScript beautifier JSON formatter YAML formatter XML formatter SQL formatter Markdown preview

Converters

Base64 encoder and decoder URL encoder and decoder Unix timestamp converter CSV to JSON JSON to CSV HTML entity encoder and decoder Number base converter Time zone converter JSON to TypeScript XML to JSON HTML to Markdown Date difference calculator

Text tools

Regex tester Remove duplicate lines Lorem ipsum generator Word counter Case converter Text diff checker

Color and images

Color converter Contrast checker Image to Base64 Image resizer

Network

Subnet calculator Download time calculator Common ports list CIDR to IP range IPv6 address expander and compressor MAC address formatter curl command builder

Server and files

Cron expression explainer chmod calculator HTTP status codes

Encoding and security

Password generator UUID generator Hash generator JWT decoder QR code generator Password strength checker Wi-Fi QR code generator