Back to Tools

JavaScript Minifier

Reduce JS file size by removing comments and whitespace

JavaScript Tool
Source Script
Compressed Code

                

Cut the size of a script before you ship it

Comments, indentation and blank lines help humans but cost bytes when a browser downloads your script. The JavaScript Minifier collapses your code into a compact single-line form and can optionally remove debugging output, giving you a smaller file to paste into a page, a bookmarklet or an embed snippet.

Using it

  1. Paste code into Source Script, or click Load Sample to see a tiny function with a comment.
  2. Review the three checkboxes under Advanced Options: Mangle Variables (Experimental), Remove console.* Logs and Remove All Comments. The last two are ticked by default.
  3. Click Minify JavaScript.
  4. Read the Compressed Code panel, check the size and character count shown beneath it, and press Copy.

What each option really does

  • Remove All Comments deletes block comments and line comments.
  • Remove console.* Logs strips calls to console.log, debug, info, warn, error, table and dir. It matches from the call to the end of the line, so a console call sitting on the same line as other code can take that code with it.
  • Mangle Variables renames names declared with var, let or const into short identifiers like _0x0. It is a plain text substitution, not a full parser, which is why it is marked experimental.

Whitespace is collapsed and the spaces around symbols such as braces, semicolons, commas and operators are removed.

Practical uses

  • Trimming an inline script for an email template or landing page where every kilobyte counts.
  • Creating a compact copy of a small utility to paste into a bookmarklet.
  • Removing leftover debug logging before sharing a snippet.
  • Getting a quick before-and-after size comparison to decide whether a real build pipeline is worth setting up.

Cautions

This is a lightweight text-based minifier, not a full compiler like Terser. Because it joins lines into one, code that depends on automatic semicolon insertion, or that has a line comment inside a template literal or regular expression, can break. Always run the minified output through your tests, and keep the original file. Leave Mangle Variables off for code that uses names in strings, such as eval or dynamic property lookups. Processing happens in your browser.

Related Articles

Related Tools







Frequently Asked Questions

Is this the same as Terser or UglifyJS?
No. It is a text-based minifier that strips comments and whitespace and optionally renames variables. It does not parse the code into a syntax tree, so it cannot perform dead-code elimination or safe scope-aware renaming like a full build tool.
Why did my minified code stop working?
The most common causes are missing semicolons, since all lines are joined into one, or a comment-like sequence inside a string or regex that was removed. Add explicit semicolons to the source, or turn off comment removal and test again.
What does Remove console.* Logs remove?
It removes console.log, debug, info, warn, error, table and dir calls, matching to the end of the line. Because of that, avoid putting other statements on the same line as a console call.
Is variable mangling safe?
It is marked experimental for a reason. Names are replaced with a text search, so a name that also appears in a string, property or another scope can be changed unintentionally. Test thoroughly or leave it unchecked.
Does it show how much smaller the file became?
It shows the size, line count and character count of the minified result. It does not calculate a percentage, so compare those figures with your original file's size to work out the reduction yourself.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.