Skip to main content
GARGLOO

JavaScript Minifier Online – Safe Minify Free

Smaller JS, same behaviour.

Runs on your deviceJavaScript

At a glance

Input:
JavaScript
Processing:
Runs locally in your browser
Privacy:
Nothing you type is sent to a server

Last updated: 2026-11-14

Common use cases

  • Shrinking a script before deploying it to production
  • Cleaning up a pasted snippet from a tutorial or a Stack Overflow answer
  • Checking what minification actually removes, rule by rule
  • Keeping a license header while everything else gets minified

About this tool

A fast, private JavaScript minifier that strips comments and whitespace without ever breaking code — a hand-written tokenizer with no dependencies, proven safe on a behaviour corpus: the original and the minified code are both executed and their observable behaviour compared.

How to use it

  1. Paste JavaScript into the editor.
  2. Click Minify JavaScript (⌘/Ctrl+Enter works too).
  3. Choose whether /*! important comments stay or go.
  4. Copy the result or download as .js.

Worked examples

Input: // Greet the user function hello(name) { const greeting = 'Hello, ' + name + '!'; return greeting; }

Output: function hello(name){const greeting='Hello, '+name+'!';return greeting;}

104 characters → 72 characters = 30.8% smaller — comments and whitespace gone, identifiers untouched.

Input: function getAnswer() { return 42; }

Output: function getAnswer(){return 42;}

The line break after `return` is KEPT — removing it would change `return;` (undefined) into `return 42`. Safe mode never joins ASI-sensitive lines.

Input: const pattern = /hello\s+world/i; const message = `Say ${'hi'}!`;

Output: const pattern=/hello\s+world/i;const message=`Say ${'hi'}!`;

Strings, template literals and regex are copied exactly — the `\s` stays `\s` and the `${...}` interpolation is untouched. 65 characters → 60 characters = 7.7% smaller.

Practical tips

  • Use Ctrl/⌘+Enter to re-run after each fix — the shortcut keeps hands on the keyboard.
  • Keep /*! ... */ on if your script carries a license header — it survives minification.
  • Minify a copy, not your only copy: keep the readable source and ship the minified file.
  • Paste the sample first — it shows comments, a loop, `continue` and a template-free string in one file.

Common mistakes

  • Minifying before debugging: read the formatted version first, minify only when size matters.
  • Pasting JavaScript with an unclosed string — the error names the exact line and column of the opening quote.
  • Expecting minification to fix broken JavaScript: it only shrinks valid scripts, it never repairs them.
  • Pasting JSX or TypeScript — this tool handles plain JavaScript only; strip types and JSX first.

How this compares

Most JavaScript minifiers in the field are server-side paste bins that upload your code, or thin wrappers around Terser that rename identifiers. This one minifies locally with no upload, never renames anything, and keeps ASI-sensitive line breaks — proven by executing the original and the minified code and comparing their behaviour on a 77-case corpus. The tradeoff: no identifier mangling and no formatting/beautifying mode — the output is smaller, not shorter-named; for readable code, pair it with a formatter.

Good to know

  • Safe minify only — identifiers are never renamed, so the savings come from comments and whitespace alone (typically 20–40% on hand-written scripts).
  • Plain JavaScript only — JSX and TypeScript syntax are not supported.
  • A regex with invalid flags, or a regex with escapes directly after a labelled block, is reported as an error instead of minified — the tool reports it, it never ships broken code.
  • The 1,000,000-character cap keeps huge scripts responsive; split larger files before pasting.

Frequently asked questions

Does minifying send my JavaScript anywhere?

No. Minification runs entirely in your browser — safe even for code with internal hostnames, API keys or tokens in comments you'd rather not leak.

What exactly does it change?

Only comments and whitespace. Identifiers are never renamed, nothing is reordered, and semicolons are never dropped — the minified file is the same program, just smaller. The sample on this page goes from 398 to 278 characters — 30.2% smaller.

What is safe mode — what are ASI-sensitive line breaks?

JavaScript inserts semicolons automatically at some line breaks (ASI). Removing the break after `return` would change `return;` (undefined) into `return 42`, and joining `a` with `(b)` on the next line would turn two statements into a function call. Safe mode keeps every line break where removing it could change meaning, and only drops the safe ones.

What happens to strings, template literals and regex?

They are copied exactly — never touched. A `//` inside a string is not a comment, a `${...}` interpolation keeps its code, and a `/` is only treated as a regex when the previous token cannot end an expression, so division (`a / b`) is never mistaken for a regex.

How large can input be, and what is not supported?

Up to 1,000,000 characters. Unclosed strings, template literals, comments and brackets are reported with the exact line and column instead of producing a broken file. Plain JavaScript only — JSX and TypeScript syntax are not supported.

All developer tools
JavaScript Minifier Online – Safe Minify Free | GARGLOO