Skip to main content
Home/Tools/Developer/JavaScript Minifier

JavaScript Minifier

Minify and compress JavaScript to reduce file size for production. Strips comments and whitespace and safely renames local variables using Terser, in your browser.

100% Private - Runs Entirely in Your Browser
No data is sent to any server. All processing happens locally on your device.

Minify and Compress JavaScript Online

This JavaScript minifier shrinks your code to the smallest valid form so it downloads and parses faster in production. It removes comments and unnecessary whitespace, drops dead code, and safely shortens local variable names — then reports exactly how many bytes you saved and the percentage reduction. The compression runs entirely in your browser, so your source is never uploaded to a server.

Why minify JavaScript?

Every byte of JavaScript a browser downloads has to be transferred over the network and then parsed and compiled before the page becomes interactive. Smaller scripts mean faster first loads, lower bandwidth bills, and better Core Web Vitals scores such as Largest Contentful Paint and Total Blocking Time. Minification typically removes 30–60% of a file's size before gzip, and the savings compound across every visitor and every page view.

Powered by Terser

Under the hood this tool uses Terser, the industry-standard minifier that powers the production builds of webpack, Rollup, and most modern bundlers. Because Terser parses your code into a real abstract syntax tree, the transformations it applies are safe: it understands scope, so renaming a local variable never collides with another, and it preserves the exact runtime behaviour of your program. This is fundamentally different from a naive find-and-replace that can corrupt strings, regular expressions, or template literals.

What gets compressed

Minification combines several passes: stripping all comments and insignificant whitespace, collapsing blocks and removing optional braces and semicolons where the grammar allows, evaluating constant expressions, eliminating unreachable code, and mangling local identifiers down to one or two characters. Names that must stay stable — global functions, object properties, and exported symbols — are left untouched so your public API keeps working.

Minify versus beautify

Minifying is the inverse of beautifying. Use this tool when you are shipping code to users and want the smallest possible payload; use the companion JavaScript formatter when you have a minified file you need to read or debug. A common workflow is to keep readable source in version control and minify only as the final step of a deploy. For best delivery results, serve the minified output with gzip or Brotli compression enabled on your server or CDN — the two techniques stack. Minification shrinks the raw source, and gzip then compresses the repeated patterns that remain, so together they typically cut the bytes on the wire by 70% or more compared with the original unprocessed file. If you ship a JavaScript library for others to consume, publish both a readable build for debugging and a minified build for production so your users can choose the right one for each environment.

Loading interactive tool...

Minify and Compress JavaScript Online

This JavaScript minifier shrinks your code to the smallest valid form so it downloads and parses faster in production. It removes comments and unnecessary whitespace, drops dead code, and safely shortens local variable names — then reports exactly how many bytes you saved and the percentage reduction. The compression runs entirely in your browser, so your source is never uploaded to a server.

Why minify JavaScript?

Every byte of JavaScript a browser downloads has to be transferred over the network and then parsed and compiled before the page becomes interactive. Smaller scripts mean faster first loads, lower bandwidth bills, and better Core Web Vitals scores such as Largest Contentful Paint and Total Blocking Time. Minification typically removes 30–60% of a file's size before gzip, and the savings compound across every visitor and every page view.

Powered by Terser

Under the hood this tool uses Terser, the industry-standard minifier that powers the production builds of webpack, Rollup, and most modern bundlers. Because Terser parses your code into a real abstract syntax tree, the transformations it applies are safe: it understands scope, so renaming a local variable never collides with another, and it preserves the exact runtime behaviour of your program. This is fundamentally different from a naive find-and-replace that can corrupt strings, regular expressions, or template literals.

What gets compressed

Minification combines several passes: stripping all comments and insignificant whitespace, collapsing blocks and removing optional braces and semicolons where the grammar allows, evaluating constant expressions, eliminating unreachable code, and mangling local identifiers down to one or two characters. Names that must stay stable — global functions, object properties, and exported symbols — are left untouched so your public API keeps working.

Minify versus beautify

Minifying is the inverse of beautifying. Use this tool when you are shipping code to users and want the smallest possible payload; use the companion JavaScript formatter when you have a minified file you need to read or debug. A common workflow is to keep readable source in version control and minify only as the final step of a deploy. For best delivery results, serve the minified output with gzip or Brotli compression enabled on your server or CDN — the two techniques stack. Minification shrinks the raw source, and gzip then compresses the repeated patterns that remain, so together they typically cut the bytes on the wire by 70% or more compared with the original unprocessed file. If you ship a JavaScript library for others to consume, publish both a readable build for debugging and a minified build for production so your users can choose the right one for each environment.

You build the idea. I'll ship the product.

Productized MVP development for founders. 9 SaaS apps shipped — yours could be next, in 6 weeks. Secure by default.

Frequently Asked Questions

Common questions about the JavaScript Minifier

Minification removes everything a browser does not need to execute your code — comments, whitespace, and long variable names — to make the file as small as possible. Smaller files download and parse faster, improving page load times and Core Web Vitals.

This tool uses Terser, which parses your code into a real syntax tree before transforming it, so the minified output behaves identically to the original. It understands scope, so renaming local variables never causes collisions, and it leaves global functions and object properties untouched. If your code has a syntax error, the tool reports it instead of producing broken output.

It depends on the code, but minification typically removes 30–60% of a file's size before gzip compression. The tool shows you the exact byte savings and the percentage reduction after each run. For even better results, serve the minified file with gzip or Brotli enabled.

They are opposites. Minifying shrinks code to the smallest valid form for production, while beautifying expands it with indentation for reading. Keep readable source in version control and minify only as the final deploy step; use the JavaScript formatter when you need to read a minified file.

No. Compression happens entirely in your browser, so your source code never leaves your machine. It is safe to minify private or proprietary scripts here.

ℹ️ Disclaimer

This tool is provided for informational and educational purposes only. All processing happens entirely in your browser - no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results. Use at your own discretion.