Loona Automation logoLoona Developer Tools
Home › Developer Tools › JavaScript Minifier

JavaScript Minifier - Conservative Compression That Respects Your Code

In short: the JavaScript Minifier removes comments and unneeded whitespace using a real tokenizer, so string contents, template literals and regular expressions are never damaged, and newlines that carry meaning (like the one after return) are always kept.

Naive minifiers that treat JavaScript as plain text break code the moment a string contains "//" or a regex contains a quote. This tool lexes your code into tokens first and only then decides what can safely be removed.

Original size-
Result size-
You saved-
Private by design: everything in this tool happens 100% in your browser with JavaScript. Your input is never uploaded to a server, never stored and never seen by us - close the tab and everything is gone.

How to use the JavaScript Minifier

  1. Paste or type your JavaScript into the top box.
  2. Click Minify JavaScript.
  3. Check the size panel to see how much was saved.
  4. Copy the result or download it as a .js file - and, as with any minifier, run your code once to confirm it behaves the same.

How it works

The tool first splits your code into tokens: identifiers, numbers, strings, template literals, regular expressions and punctuation. Comments are recognised during this scan and dropped, and the scanner knows the difference between a division sign and the start of a regex, and never looks inside a string for comment markers. Tokens are then re-joined, adding a separating space only where removing it would change the meaning - between two words, between a plus and another plus, and so on. Newlines are kept wherever JavaScript's automatic semicolon insertion makes them meaningful, most importantly after return, break and continue, and before a leading ++ or --.

Worked example

A commented utility function of about 400 bytes typically compresses to around 260 bytes - roughly a third smaller - while a string like "see https://example.com // docs" inside it comes through completely untouched.

Frequently Asked Questions

Is this JavaScript minifier free?

Yes - completely free, with no sign-up, no size limit and no daily cap.

How is this different from a full build-tool minifier?

Build tools like Terser also rename variables and rewrite code, which squeezes out a few more percent. This tool is deliberately conservative: it never renames anything and never rewrites expressions, so the output is easy to eyeball and safe for quick one-off use.

Can it break my code?

It is designed not to: strings, template literals and regex literals are protected, and meaning-carrying newlines are preserved. No minifier can promise perfection on every exotic pattern, so always run your test suite or open the page once after minifying - that advice applies to every minifier, including ours.

Does it handle regular expressions and template literals?

Yes. The tokenizer recognises regex literals (including character classes and escapes) and template literals, including nested ${ } expressions, and carries them through unchanged.

Is my code uploaded to a server?

No. Tokenising and minifying happen 100% in your browser. Your source code never leaves your device.

Related Developer Tools

Embed this tool on your website — free

Add this tool to your own website or blog — it is completely free, needs no sign-up, and always shows the latest version. Copy the code below and paste it into your page where you want the tool to appear. Keeping the small “Powered by Loona Automation” credit line under the embed helps keep this tool free — but you are free to style or remove it; the tool works either way.