HubTools

JavaScript Minifier

Minify JavaScript code by removing whitespace, comments, and unnecessary characters.

What is JavaScript Minification?

JavaScript minification is the process of removing every byte from a script that doesn't affect its execution: comments, indentation, blank lines, optional semicolons, and unnecessary parentheses. Aggressive minifiers go further — renaming local variables to single characters, inlining short constants, and dead-code-eliminating unreachable branches. The output is functionally identical to the input but typically 30–50% smaller before gzip. Combined with brotli, you get another 15–30% reduction. Since JavaScript is parser-blocking on initial load, minified code directly improves Time to Interactive on mobile. Production bundlers (Vite, webpack, esbuild) ship terser, swc, or esbuild's own minifier as part of the build — but for one-off snippets, this tool runs the same kind of pass in your browser. Pair it with the CSS Minifier and HTML Minifier for a complete static-site optimization pass.
Input JavaScript
Minified Output
Original Size
0bytes
Minified Size
0bytes
Savings
0.0%
Options
Remove Comments
Collapse Whitespace
Remove Operator Spacing
Remove Blank Lines

How to use this tool

  1. 1
    Paste your JavaScript
    Drop your source code into the input editor. ES2015+ syntax including template strings, classes, and async/await is supported.
  2. 2
    Click Minify
    The output editor shows the compressed JS instantly, along with the original size, minified size, and percentage saved.
  3. 3
    Copy or download
    Use the Copy button to grab the minified code for your build pipeline, or Download to save as a .min.js file.

Frequently asked questions

What does JavaScript minification remove?
Single-line and block comments, redundant whitespace, optional semicolons handled by Automatic Semicolon Insertion (ASI), and unnecessary parentheses. Aggressive minifiers also rename local variables to single characters, inline constants, and shorten boolean literals (true → !0, false → !1). Typical savings on hand-written JS are 30–50%.