Skip to main content
Tools Star Hub

JavaScript Minifier

Minify JavaScript in your browser with a parser. The code is not executed.

What is JavaScript Minifier?

A JavaScript minifier shrinks JS source in the browser using Terser, without sending code to a server.

Loading tool…

This tool runs in your browser. Inputs, files and generated values stay on this device. Favorites and recently used tools, if you use them, store only tool names in local storage — never passwords, documents or QR contents. See the privacy policy.

JavaScript Minifier — Parse and Minify in Your Browser — Tools Star Hub

What this tool does

Parse JavaScript with Terser, then compress and mangle it. Use it when a small script should be shorter and you want a parser rather than find-and-replace. The script is not run, and TypeScript comes back as an error.

How to use

  1. Paste JavaScript into the left box.
  2. Press Minify. A parser compresses and mangles the source without running it.
  3. Copy the result or clear both boxes. Syntax errors are shown instead of output.

Examples

  • A small function

    function greet(name) { return "Hello, " + name; } is parsed, then shortened by removing whitespace and renaming locals where safe.

  • Invalid source

    If the parser cannot read the file, you get an error. The tool does not try to “fix” broken JavaScript.

How it works

JavaScript cannot be minified safely with simple find-and-replace. This tool uses Terser in the browser to parse the source, then compress and mangle it. Your code is not executed with eval or new Function. Constant-expression evaluation is turned off so user expressions are not run during minify. Very large files are rejected so the tab stays responsive.

Limitations

Terser parses the source, then compresses and mangles it. The script is not run. TypeScript, and JavaScript the parser cannot read, come back as an error rather than a shorter file. Constant expressions are not evaluated during the pass.

See the disclaimer for what these tools do not cover.

FAQ

Is the JavaScript Minifier free?
Yes. Parsing and minifying JavaScript in this browser is free, with no account.
Does this run my JavaScript?
No. The source is parsed and rewritten. It is not executed in this page.
Will every program minify?
Only syntactically valid JavaScript. Browser-incompatible syntax or truncated files will fail with a parser error.
Is my input sent to a server?
No. The source is minified in this tab. It is not uploaded and not saved in local storage.