JavaScript Minifier
Minify JavaScript.
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
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 //?
Does it rename variables?
Is it safe for code without semicolons?
Is my code uploaded?
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 YouTubeTypeScript in 100 Seconds
Fireship
Typed JS snippets often get formatted or hashed nearby.
Watch on YouTube
- MDN Web Docs
MDN
Primary reference for web APIs these developer tools touch.
- Introduction to JSON Web Tokens
jwt.io
JWT structure for decoder and debugger pages.