Skip to main content
Programming Language Tools

JavaScript Minifier

Instantly compact JavaScript by removing unnecessary whitespace, right in your browser.

Paste your JavaScript below to instantly compact it - entirely in your browser, nothing is sent to our servers.

This safely compacts whitespace and blank lines. It does not strip comments, since doing that safely requires fully parsing your code - and getting it wrong could break strings or regular expressions that contain comment-like characters.

JustChecker builds tools that respect your data - this one never leaves your browser.

What Is the JavaScript Minifier?

It compacts JavaScript by removing unnecessary whitespace and blank lines, in your browser.

When to Use It

  • To shrink a small script for an embed or inline snippet.
  • When you do not have a build tool set up.

How to Use It

  1. Paste your JavaScript.
  2. Minify and copy the output.

Understanding the Result

The code runs the same way. Comments are kept, because removing them safely requires fully parsing the code - comment-like text can appear inside strings and regular expressions.

Limitations

This is a safe whitespace compactor, not a full minifier: it does not shorten variable names or remove unused code. For production builds use a bundler such as esbuild, Terser or Vite.

Example

function greet(name) {

    const message = 'Hello, ' + name;
    return message;
}

is compacted to fewer lines with indentation and blank lines removed, while every statement stays exactly as written.

Why a "Safe" Minifier?

Real minifiers such as Terser and esbuild parse the whole program before changing it. Tools that remove comments or line breaks with simple patterns can break code - for example, a // inside a URL string, or a line break that JavaScript's automatic semicolon insertion depends on. This tool avoids those risky changes, so the output always behaves like the input.

Minification vs Compression

TechniqueTypical savingWhere
Whitespace removalSmall to moderateThis tool
Full minification (renaming, dead code)Often 30-60%Terser, esbuild, bundlers
Gzip / Brotli on the serverOften 60-80% moreWeb server or CDN

For a production site, use a bundler and make sure compression is on - check it with the GZIP Checker. To make minified code readable again, use the JavaScript Formatter.

Frequently Asked Questions

No - this tool runs entirely in your browser using JavaScript. Nothing you paste is transmitted anywhere.

No, deliberately - safely stripping comments requires fully parsing your code to distinguish real comments from "//" or "/* */" sequences that happen to appear inside strings or regular expressions. Getting this wrong could silently corrupt your code, so this tool only performs safe whitespace compaction.

A proper build-time minifier like Terser or esbuild, which fully parses your code into an AST before transforming it, is the safe way to do more aggressive minification.
Share this tool: