JavaScript Minifier

Minify JavaScript.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Paste JavaScript and get a smaller version with comments and unnecessary whitespace removed. Strings, template literals and regular expressions are left exactly as written, so a URL such as http://example.com is never mistaken for a comment.

How to use

1
Step 1
Paste your JavaScript into the Input box.
2
Step 2
Press Run.
3
Step 3
Copy the minified code.

How it works

The code is split into tokens first: strings, template literals, regular expressions, comments and everything else. Comments are dropped, and whitespace is kept only where removing it would join two words or change meaning. Newlines are kept where automatic semicolon insertion could matter. Names are not shortened and code is not rewritten.

Worked example

A URL string and a comment

Input
const url = "http://x.com"; // base function add(a, b) { return a + b; }
Output
const url="http://x.com";function add(a,b){return a+b;}
Walkthrough
The comment and spaces are gone; the // inside the string is untouched.

Limitations

  • It only removes whitespace and comments. Variable names are not shortened, so savings are smaller than with Terser.
  • Regex detection is heuristic; very unusual code after a closing brace may be misread.
  • Syntax errors are not reported.

Questions

Will it break strings that contain //?
No. Strings, template literals and regex literals are copied unchanged.
Does it rename variables?
No, it only removes comments and whitespace.
Is it safe for code without semicolons?
Newlines that may act as statement ends are kept.
Is my code uploaded?
No, it runs in your browser.

Features

  • Token-aware
  • Strings and regex preserved
  • Keeps ASI-safe newlines
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • How base64 encoding works

    Andrew Schmelyun

    Mental model for Base64 encode/decode tools.

    Watch on YouTube
  • TypeScript in 100 Seconds

    Fireship

    Typed JS snippets often get formatted or hashed nearby.

    Watch on YouTube