Input

Minified Output

What Is the JavaScript Minifier?

The JavaScript Minifier removes whitespace, comments, and shortens code to reduce file size. Smaller files load faster. The ECMAScript specification defines the language; minification preserves behavior while shrinking output. Tools like Terser and UglifyJS use similar techniques in production builds.

This tool runs entirely in your browser. Nothing is sent to a server. Paste JS or upload a file; get minified output. For formatting (the reverse), use JavaScript Formatter. For validation, use JavaScript Validator. For stronger protection, use JavaScript Obfuscator.

How to Use This Tool

1

Paste or Upload

Paste JavaScript into the left panel or upload a .js or .txt file. Use Sample to load example code. Use Clear to reset.

2

View Minified Output

The right panel shows minified code. Whitespace and comments are removed. Invalid JS will show an error.

3

Copy or Download

Use Copy or Download to get the minified code. For production, consider also using gzip or brotli compression.

JavaScript Minifier Examples

Here is an example of minifying formatted JavaScript code.

Example: API fetch function

Formatted input:

Input

Minified output:

Output

When the JavaScript Minifier Helps

When preparing production bundles with webpack or rollup, reducing bandwidth, or optimizing load times, minification shrinks JS files. Use with build tools or manually for quick checks. For obfuscation (harder to reverse), use JavaScript Obfuscator.

Frequently Asked Questions

Is my data private?

Yes. Minification runs entirely in your browser. No data is sent to any server.

Minifier vs Obfuscator?

Minifier shrinks code for size. Obfuscator makes code harder to read and reverse-engineer. Obfuscation often includes minification.

Does it break my code?

Valid minification preserves behavior. Semicolon insertion and edge cases can cause issues; test the output.

What about source maps?

This tool does not generate source maps. For production builds with source maps, use webpack, rollup, or Vite. See MDN on source maps.

Can I unminify?

Use JavaScript Formatter to add indentation. It does not restore comments or original variable names.

Related Tools

ECMAScript. MDN JavaScript. Terser. webpack. rollup.