Digital marketing agency in Lahore: SEO, content, ads, and websites.

+971 52 821 8996 | info@marketers.pk

Free tools / Performance

JavaScript Minifier

Remove comments and blank space from JavaScript while leaving strings, templates and regexes untouched.

Minify JavaScript (conservative)

Removes comments, indentation and blank lines only. Strings, template literals and regular expressions are recognised and left alone; nothing is renamed or restructured, so the code behaves exactly as before. Runs in your browser.

For a production build use a real minifier such as esbuild or terser: they parse the code, shorten names and drop dead branches, and typically halve a file. This tool is for scripts you cannot run a bundler over.

Before—
After—
Saved—

Minified JavaScript

javascript
 
(01) About this tool

What the JavaScript Minifier does

This is a conservative JavaScript minifier. It removes // and /* */ comments, collapses blank lines and indentation, and trims the end of each line. It does not rename variables, inline functions, drop dead code or rewrite syntax, which is what esbuild, terser and swc do to reach their small outputs. The trade is deliberate: nothing here can change what your code does, so it is safe to use on a script you cannot run a bundler over.

Comment removal is the part that usually goes wrong in simple tools, because a // inside a URL string or a /* inside a regular expression looks like a comment. This minifier scans the code with a small state machine that knows when it is inside a single-quoted or double-quoted string, a template literal (including the expressions inside ${ }), or a regex literal, and only strips comments outside them. Line breaks that separate statements are kept so code that relies on automatic semicolon insertion keeps working.

Paste the script, read the size change, copy or download. For a production bundle the honest advice is to use a real build step; the page says so because a minifier that cannot restructure code will never match a bundler on size. For an inline snippet, a tracking tag or a small plugin file, this gets the comments and whitespace out of the way without the setup.

(02) How to use

Step by step

  1. 01Paste the JavaScript into the input box.
  2. 02Choose whether to keep /*! licence comments (on by default).
  3. 03Read the before and after sizes; the saving is mostly comments and indentation.
  4. 04Copy the output, or download it as a .min.js file next to the original.
  5. 05Run the page once with the minified file to confirm it behaves as before.
(03) FAQ

Common questions

JavaScript inserts semicolons at line ends in places where you did not write them. Joining every line into one would turn "return" followed by a value on the next line, or a statement that begins with a parenthesis, into different code. Keeping one newline per statement costs a byte each and keeps the semantics.

No. The scanner tracks string, template and regex state character by character, so https://example.com inside quotes is left alone, and a regex such as /\/\*/ is recognised as a pattern rather than a comment.

Those tools parse the code into a syntax tree and shorten names, fold constants and remove unreachable branches, which typically halves a file. This tool only removes what a parser skips. Expect 10 to 30 percent here depending on how much was comments and indentation.

Not reliably. JSX text content and TypeScript generics contain characters the scanner treats as operators. Compile those first and minify the plain JavaScript output, or let the compiler minify, which it already can.

(04) Related tools

Keep checking

All tools

Want these fixes done for you?

Our team runs the audit, makes the changes and reports the result.

Get a free proposal
Work with us

Ready to grow your traffic, leads and sales?

Tell us about your business and goals. We'll reply with a clear plan for SEO, content, ads or a new website, and what it will take to get results.