Skip to content
trustedonlinetools

JavaScript Minifier

Minify JavaScript by removing whitespace, renaming variables, and eliminating dead code — processed entirely in your browser so proprietary source stays private.

What JavaScript minification does and why you need it

JavaScript minification reduces file size by removing characters that are meaningful to humans but irrelevant to the JavaScript engine: whitespace, line breaks, comments, and verbose variable names. Smaller files download faster, parse faster, and reduce bandwidth costs — a meaningful improvement for production web applications.

This tool uses Terser, which parses JavaScript into an AST, then applies dead-code elimination, variable renaming (mangling), and whitespace/comment removal — the code behaves identically but is significantly smaller. Note that Terser does rename local variables to shorter names, so the output is not human-readable.

How Terser processes your code

Terser first parses your JavaScript into an Abstract Syntax Tree, validating syntax along the way. It then runs a compress pass that evaluates constant expressions, removes unreachable code after return/throw statements, collapses variable declarations, and inlines single-use variables where safe.

After compression, the mangle pass renames local variables and function parameters to short single-character names (a, b, c, etc.). Terser's mangling only affects local variables — not globals, not exported names, and not property accesses. This means the minified code integrates safely with the rest of your application without breaking external references.

Privacy and browser-based processing

The entire minification runs in your browser — your JavaScript is never sent to any server, so you can safely paste proprietary code, trade secrets, or security-sensitive logic without concern. No data is transmitted, logged, or persisted beyond your browser tab.

This makes the tool appropriate for minifying internal libraries, pre-release code, and snippets containing business logic you would not want exposed to third-party build services.

Tips and things to know

Minified code is harder to debug because variable names are replaced with short identifiers. In production, pair minified bundles with source maps so browser DevTools can reconstruct the original source. This tool produces the minified output only — source map generation requires your build pipeline.

ES module syntax (import/export), async/await, optional chaining, and nullish coalescing are all fully supported. If Terser encounters a syntax error, it will report the location rather than producing broken output. Also note that top-level variables are not mangled by default to avoid breaking references from other scripts.

Frequently asked questions

Is my code sent to a server for minification?

No. Terser runs entirely in your browser as a JavaScript library. Your code never leaves your machine and nothing is stored or logged.

Does minification change what my code does?

No. Terser's transformations are semantics-preserving. The code executes identically — it is just smaller and not human-readable due to variable renaming and whitespace removal.

Will minification rename my exported functions or global variables?

No. Terser only mangles local variables and function parameters. Globals, exports, and property names are left intact so external code that references them continues to work.

How much smaller will my code be?

Typical reduction is 40-70% depending on the original code style. Code with long variable names, many comments, and generous whitespace sees the largest savings.

Can I debug minified code?

Minified code is difficult to read because variables are renamed to single characters. For production debugging, generate source maps in your build tool so browser DevTools can map back to the original source.

Does the minifier support ES modules and modern syntax?

Yes. Terser fully supports ES2024+ syntax including import/export, async/await, optional chaining, nullish coalescing, and top-level await.