Skip to content
Web & Developer

JavaScript Minifier

Removes comments and unnecessary whitespace from JavaScript to reduce file size. Since JavaScript is usually the heaviest thing a page downloads, and it must be parsed before it can run, size reductions translate directly into faster interactivity.

Free, no signupRuns entirely in your browser
Input
Result
function factorial(n){if(n<=1)return 1;return n*factorial(n-1);}console.log(factorial(5));
About

What the JavaScript Minifier does

This performs safe whitespace and comment removal. Production build tools go considerably further — renaming variables, removing dead code and inlining functions — which is why a bundler like esbuild or Terser will always beat a standalone minifier for shipping code.

How it works

Using the JavaScript Minifier

  1. 1Paste your JavaScript.
  2. 2Line and block comments are removed.
  3. 3Redundant whitespace and indentation are stripped.
  4. 4String contents and regular expressions are preserved intact.
  5. 5Copy the minified output.
Use cases

What people use it for

  • Shrinking a small standalone script
  • Compacting an inline snippet for a page head
  • Reducing the size of a code sample for embedding
  • Quick size reduction without a build pipeline
FAQ

Frequently asked questions

6 related

Related tools

All tools →