Home/JS Minifier

JS Minifier – Compress JavaScript Code Online Free

4.5 Rating from 107 people who voted
Share this page
JavaScript Input Paste your JavaScript code below
Minification Options
Minification Results

About the JS Minifier

The JS Minifier shrinks your JavaScript files by removing comments, extra whitespace, and empty lines, without changing how your code executes. Paste your script, choose which optimizations to apply, and get a compressed version instantly, along with a clear breakdown of exactly how many bytes you saved. Once minified, you can format any related markup with the HTML Minifier or stylesheet with the CSS Minifier for a fully optimized page.

This tool is built for developers and website owners looking to reduce JavaScript file size and speed up page load times before deployment. It safely strips single-line and multi-line comments while preserving URLs containing “//”, so links inside strings aren’t accidentally broken. If you need to reformat minified JavaScript back into readable code, pair this with the JS Beautifier.

We tested this tool with different JavaScript files containing comments, URLs, and string literals to make sure the compressed code continues to work as expected.

How to Use the JS Minifier

  • Paste your JavaScript code into the JavaScript Input box.
  • Enable Remove Comments to strip out single-line and multi-line comments.
  • Enable Remove Extra Whitespace to collapse spaces around brackets, operators, and punctuation.
  • Enable Remove Empty Lines to eliminate blank lines from the code.
  • Click Minify JavaScript to generate the compressed result.
  • Review the Original Size, Minified Size, and Saved stats.
  • Click Copy Code or Download .js to save your minified script.

Example Usage

Input:

function example() {
  // print a greeting
  console.log('Hello World');
}

Output (all options enabled):

function example(){console.log('Hello World');}

The comment, extra whitespace, and line breaks are all removed while the script’s behavior stays exactly the same. If you ever need to make compressed code readable again, use our JS Beautifier.

Frequently Asked Questions

No, minification only removes comments, whitespace, and empty lines. The logic and functionality of your script remain exactly the same.

No, the tool is designed to avoid stripping “//” when it appears inside a URL string like <https://example.com>, so links inside your code stay intact.

Savings vary by script, but removing comments, whitespace, and empty lines typically reduces file size by 20-40%, which helps with page load speed.

Minification doesn’t directly affect SEO, but smaller JS files load and execute faster, which can improve Core Web Vitals scores, a factor in Google’s ranking.

Yes, this tool is completely free with no signup required.