JS Minifier

Minify, beautify, and validate JavaScript with compression stats, code analysis, and an optimization report — all local to your browser.

Loading tool…

What JavaScript minification does

Minifying JavaScript is more involved than minifying CSS, because the transformation has to preserve program behaviour exactly. A minifier parses the source into a syntax tree, then re-emits it without whitespace, comments, or unnecessary punctuation, and typically renames local variables to single letters — calculateTotalPrice becomes a inside its own scope.

The renaming is where most of the saving comes from, and it is safe only for names the engine can prove are local. Anything reachable from outside — exported functions, global objects, properties accessed by string — must keep its name. This is also why minified code makes stack traces useless, and why production builds ship source maps: a separate file mapping the compressed output back to your original lines so you can still debug what users are running.

Why we built this tool

Scripts are the heaviest part of most pages and the most expensive to process, since bytes must be downloaded, parsed, compiled, and executed. Cutting them is one of the highest-value performance changes available, particularly on mid-range phones.

The code you are minifying is your product, sometimes before release, and occasionally contains an API endpoint or key that should not be there. Sending it to a stranger's server to save a few kilobytes is a poor bargain. Our minifier runs the whole parse-and-emit cycle in your browser, so your source never leaves the tab, there is no file-size limit, and no copy is retained anywhere. Once the page is loaded it works with the network off.

Tips and common mistakes

  • Always test the minified output before deploying it; minification is where subtle behavioural bugs surface.
  • Code relying on function names at runtime, or on property access by string, can break when names are shortened.
  • Generate and keep source maps so production stack traces remain readable.
  • Never minify code containing API keys as a way of hiding them — anything shipped to a browser is readable.

Open JS Minifier with a link

JS Minifier can be handed its input by the link that opens it, so the page arrives with the work already done. This is meant for assistants and scripts: if a chatbot, an editor extension, or a command-line agent already holds your content, it can build a link instead of asking you to copy and paste into a box.

The payload rides in the fragment — the part of a URL after the #. Browsers never send the fragment to a server, so anything handed over this way stays on your device exactly as a dropped file would. A link that uses the query string instead is rewritten into the fragment by the page before any analytics or ad script can read the address.

Prefix any field with gz#gztext= — to pass it as gzip-compressed base64url, which fits roughly five to ten times more into the same link. Links stay reliable up to about 8,000 characters; past that, chat apps and address bars start truncating them, and the page says so rather than loading half a document.

One exception to the privacy rule: ?url= tells the page to download the input from an address. That request goes from your browser straight to that server — not through ours — but it does leave your device, and it only works if the server allows cross-origin requests.

With My Gadgets installed as an app, a .js file opened from your desktop lands straight in this tool. The file is read locally, exactly like a drop.

  • #text= — the text to work on

Example: https://mygadgets.ink/tools/js-minifier/#text=...

Quick start: using JS Minifier

  1. Paste your JavaScript or load the .js file above.
  2. Run the minifier and check the size reduction reported.
  3. Test the minified output in your application before deploying it.
  4. Keep your unminified source in version control — minification is not reversible.
  5. Serve the file with gzip or Brotli compression for a further saving.

Pair it with CSS Minifier and HTML Minifier to trim the whole page.

Related Developer Tools

Browse all Developer Tools →