DevToolbox

JS Minifier

Compress JavaScript by removing whitespace

InputPaste or type JavaScript
Loading...
Output

Output will appear here

Related tools

What is JavaScript minification?

JavaScript minification removes unnecessary characters from source code — whitespace, comments, and line breaks — without changing functionality. Advanced minification also shortens variable names and simplifies expressions. This tool processes your code entirely in the browser.

Why minify JavaScript

Minifying JavaScript removes whitespace, line breaks, and comments to shrink the file the browser must download and parse. Because scripts are often the largest and most expensive part of a page to load and execute, reducing their size directly improves load time and interactivity — a key factor in Core Web Vitals.

Minification preserves behaviour exactly: the program runs the same, it is simply delivered in fewer bytes.

Minification and your source

Write and maintain readable JavaScript, and minify as a build step before deploying. Keeping the formatted source as your working copy while serving the minified file to users gives you smaller downloads without sacrificing maintainability. For deep size reductions, production build tools also rename local variables, which this quick minifier leaves untouched.

Minifying, bundling, and compression

In a production pipeline, minification is one of several steps: a bundler combines modules, minification removes whitespace and comments, and the server compresses the result with gzip or Brotli. Each step reduces size differently, and together they make scripts load far faster than the original source.

How to minify JavaScript

  1. 1Paste your code. Paste the JavaScript you want to compress.
  2. 2Click Minify. Whitespace, line breaks, and comments are removed to shrink the file.
  3. 3Copy the result. Use the minified code in production; keep your formatted source for editing.

Examples

Compress a function

Input

function add(a, b) {
  // sum
  return a + b;
}

Output

function add(a,b){return a+b}

Bytes saved

Input

Formatted: 110 bytes

Output

Minified: 41 bytes (about 63% smaller)

What JS minification removes

Bytes stripped without changing behaviour.

RemovedKept
CommentsStatements and logic
Whitespace and newlinesVariable and function names
IndentationString and value contents
Redundant spacesProgram behaviour

Frequently asked questions

Does minifying change what my code does?+

No. Minification only removes whitespace and comments. The program behaves identically; it is just smaller.

Why minify JavaScript?+

Scripts are often the heaviest part of a page to download, parse, and run. A smaller file loads and becomes interactive faster, improving Core Web Vitals.

Does it rename my variables?+

This quick minifier removes whitespace and comments but keeps names readable. Full production bundlers also shorten local variable names for further savings.

Should I keep the original code?+

Yes. Maintain your formatted source and minify as a build step, so your code stays editable while users get the compressed file.

Is my code private?+

Yes. Minification runs in your browser; nothing is uploaded.

Is it free?+

Yes — free with no limits.

Is minified code the same as obfuscated code?+

No. Minification shrinks code while keeping it functional; obfuscation deliberately makes code hard to read. Minified code is simply compact, not hidden.