Code Tools

JS Minifier

All tools

Compact a script by dropping comments and spacing, while string contents stay exactly as written.

How it works

Four simple steps

1

Paste JavaScript

Add a snippet or drop a .js file, ideally with semicolons in place.

2

Comments stripped

Line and block comments are removed; strings are left alone.

3

Spacing collapsed

Only spaces between identifiers and keywords survive.

4

Test and save

Copy the result or download min.js, then run it once to confirm.

JS Minifier

About JS Minifier

You have a bookmarklet, an analytics snippet or a small widget script that needs to fit on one line in a CMS field. A full bundler is overkill, but deleting whitespace by hand risks breaking a string.

The minifier scans the code once, tracking whether it is inside a string, a // comment or a /* */ comment. Comments are dropped. Whitespace is removed unless it separates two identifier characters, so const x keeps its space while spaces around operators and braces disappear. Characters inside single, double and backtick quotes are copied untouched. Output updates live and downloads as min.js.

The important limit is that line breaks are not treated as statement ends. Code that relies on automatic semicolon insertion, such as two assignments on separate lines without semicolons, is joined into one invalid line. Add semicolons first and test the result. Regex literals containing quote characters or // can also be misread as strings or comments, and variable names are not shortened. To read the output again, use the JavaScript Formatter. For config payloads the JSON minifier is safer because it parses the data, and you can compress your styles the same way.

The code is only scanned for whitespace and comments in this tab; it is never executed or sent anywhere.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

No. It only removes comments and whitespace. Renaming, dead code removal and other compression require a real parser, which this lightweight tool does not include.

No. Every comment is removed, including /*! ... */ license banners. Paste the banner back at the top of the output if your license requires it.

The usual cause is a missing semicolon at the end of a line. Once line breaks are gone, the next statement runs straight on. Add semicolons to the source and minify again.

View more FAQs

Related tools

View all

HTML Formatter

Beautify and indent HTML markup.

Open

CSS Formatter

Format and pretty-print CSS.

Open

JS Formatter

Beautify JavaScript code.

Open

JSON Formatter

Beautify and validate JSON.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools