Skip to main content
Website Tools

JavaScript Minifier

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

Free & instant No signup How to use FAQ
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.
Not sure what to enter?

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

What is JavaScript minification?

JavaScript minification strips comments and unnecessary whitespace from scripts so they download and parse faster. This tool compacts your code in the browser; for production builds, a bundler minifier (such as Terser or esbuild) can go further by shortening variable names.

How to compact JavaScript

  1. Paste your JavaScript into the box above.
  2. Click Compact JavaScript.
  3. Check the size saving, then click Copy Result.
  4. Keep the original source for editing and test the compacted script before deploying it.

Related checks

Keep the original file for editing and serve the minified copy with Gzip or Brotli for the smallest download. Minification runs in your browser, so your source code never leaves your computer.

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:
Need a website for your business? Only $599