100% PrivateNo Server UploadPreserves String Literals

How It Works

1

Paste Code

Paste your JavaScript code into the input area.

2

Minify

Click Minify to remove comments and unnecessary whitespace.

3

Copy Result

Copy the compressed output with size reduction stats.

Frequently Asked Questions

What is the difference between minification and obfuscation?
Minification removes unnecessary characters (whitespace, comments, semicolons) without changing the code logic, making it smaller but still readable if reformatted. Obfuscation deliberately makes code hard to understand by renaming variables, rearranging logic, and adding dead code. This tool performs minification only.
Why should I minify JavaScript?
Minifying JavaScript reduces file size, which means faster downloads and page loads for your users. Smaller files also reduce bandwidth costs and improve Core Web Vitals scores like Largest Contentful Paint. Most production websites serve minified JavaScript.
Does minifying JavaScript break code?
Proper minification should never break code. This tool removes only whitespace and comments while preserving string literals, regular expressions, and all code logic. However, if your code relies on Function.toString() or similar reflection, the output may differ from the original formatting.
What are source maps and why do they matter?
Source maps are files that map minified code back to the original source. When you debug in browser dev tools, source maps let you see and set breakpoints in the original, readable code. Build tools like Webpack and Vite generate source maps automatically during the build process.
Should I use a build tool instead of an online minifier?
For production projects, build tools like Webpack, Rollup, esbuild, or Vite provide minification as part of the build pipeline along with tree shaking, code splitting, and bundling. This online tool is useful for quick one-off minification, testing, or when you need to compress a standalone script without a build setup.
Share:

About JS Minifier

What this tool does

Formatter tools beautify and standardize code in JSON, SQL, CSS, HTML, JavaScript, XML, and YAML. They also minify code for production use, reducing file size by stripping whitespace and comments.

Why use this tool

Readable code is easier to debug. When you paste a minified JSON response or a one-line SQL query, formatting it with proper indentation reveals structure instantly. Conversely, minifying before deployment shaves kilobytes off your bundles.

How it works

The tool parses your input into an abstract syntax tree (or token stream), then serializes it back with consistent indentation, line breaks, and spacing rules. Minification does the reverse: it removes all non-essential whitespace.

Pro tip

Set your indent size to 2 spaces for JSON and JavaScript, 4 spaces for Python. These are the most widely used conventions and will minimize diff noise when collaborating.

Love this tool? Explore 12467+ more

Free online tools for images, PDFs, text, code, and more. All running in your browser.

Explore All Tools