JavaScript Minifier

Free online JavaScript minifier and JS compressor that shrinks your code by up to 60%. Removes comments, whitespace and unnecessary characters without changing how your code runs. Choose whether to keep license comments, then copy or download the minified file ready to ship. Runs entirely in your browser — no signup, no uploads.

Paste Your JavaScript

Readable JS in, tiny JS out
Pro tip: Press Ctrl+Enter (or Cmd+Enter) inside the textarea to minify instantly. This minifier only removes comments and whitespace — it does not rename variables or transform logic.

Output

Ready when you are

Your minified JavaScript will appear here

Paste some JS and click Minify JavaScript to shrink it.

What does this JavaScript Minifier do?

This free online JavaScript minifier (also called a JS compressor) removes every byte that a browser does not need: whitespace, line breaks, indentation and regular comments. The result is a much smaller script that behaves exactly the same when run but downloads faster and improves your PageSpeed score.

Minification is one of the easiest performance wins for any website. A typical hand-written JavaScript file loses 30–50% of its size the moment you minify it, and files that carry a lot of comments and indentation can shrink by 60% or more. For high-traffic sites, that translates into real savings on bandwidth and real improvements in Core Web Vitals.

The tool has a couple of sensible options so you can control exactly what happens. You can preserve important comments (the ones starting with /*!) — this is the convention for license headers and legal notices. You can also let the minifier add semicolons after closing braces where ASI (Automatic Semicolon Insertion) might otherwise kick in — safe by default and helps avoid subtle bugs when you concatenate multiple minified files.

Everything runs locally in your browser. The code you paste never leaves your device, there is no signup, and there are no usage limits. Minify as much JavaScript as you want, as many times as you want, for personal or commercial projects.

How to minify JavaScript code

  1. Paste your JavaScript into the input box on the left. Any readable script works — hand-written, exported from a bundler, or the output of a TypeScript build.
  2. Choose your options. Keep important comments on if your file has license headers. Leave the semicolon safety on unless you know your code is safe without it.
  3. Click Minify JavaScript. The tool rewrites your script in a compact form and shows the result on the right.
  4. Check the savings. The stats panel shows your input size, output size, bytes saved, reduction percentage, and the number of lines in the output.
  5. Copy or download. Use Copy Output to grab the minified JS, or Download .min.js to save it with the conventional filename suffix.

Why use this JavaScript Minifier?

Instant compression

Minification happens in your browser the moment you click. No server round-trip, no waiting, no upload limits.

Safe by default

Preserves license comments, keeps needed spaces between tokens, and adds semicolons where ASI edge cases might break concatenated files.

Live stats

See input size, output size, bytes saved, reduction percentage and total lines — all updated the moment you minify.

Modern ES syntax

Understands template literals, arrow functions, optional chaining, nullish coalescing, async/await, classes and private fields.

100% private

Everything runs locally. The code you paste never leaves your device — no server, no logs, no tracking.

Works offline

Once the page loads, you can minify JavaScript without an internet connection. Bookmark it for offline work.

What exactly gets removed?

Here is a complete list of what the minifier strips out and what it preserves, so you know exactly what to expect.

ElementDefault behaviourNotes
Whitespace & line breaksRemovedSpaces, tabs, newlines between tokens
IndentationRemovedEntire leading whitespace is dropped
Regular comments (// and /* */)RemovedNo effect on runtime
Important comments (/*! ... */)Preserved (toggleable)Convention for license and legal headers
Spaces between operatorsRemoveda + b becomes a+b
Spaces around keywordsRemoved when safeif (x) becomes if(x), but typeof x keeps its space
String literalsPreserved exactlyContents inside '...', "..." and backticks are never touched
Template literalsPreserved exactly${...} expressions inside are treated as part of the string
Regex literalsDetected and preservedHandled with the keyword/punctuation heuristic
Identifiers & variablesUntouchedNo renaming, no scope analysis
Function namesUntouchedNames remain the same
Syntax & behaviourIdenticalOnly whitespace and comments are changed

If you need the smallest possible file, look at dedicated tools like Terser or esbuild — they perform variable renaming, dead-code elimination and constant folding on top of the whitespace-level minification this tool does.

Who uses a JavaScript minifier?

Anyone who ships a website or web app cares about JavaScript size. Here are the most common use cases:

Front-end and full-stack developers

  • Minify JS before deploying to production, as a one-off or as part of the build pipeline
  • Quickly shrink an inline script embedded in a single HTML file
  • Compare input and output byte counts to report compression savings to the team
  • Strip leftover debug comments from a script that was shared by a contractor

SEO and performance engineers

  • Reduce JS file size to improve First Input Delay (FID) and overall PageSpeed score
  • Trim render-blocking JavaScript on the critical path so above-the-fold content paints sooner
  • Audit large third-party scripts before deciding whether to keep them

No-code and CMS users

  • Minify custom JS injected through a website builder or theme settings
  • Clean up exported snippets from a design tool before pasting them into a live site

Students and learners

  • See how much whitespace and comments contribute to file size
  • Understand the practical difference between beautified and minified JavaScript

JavaScript minify vs. JavaScript beautify — what is the difference?

These two operations are opposites, and each has its own job.

ModeWhat it doesBest forTypical size change
Minify (this page)Removes whitespace and comments. Collapses code into the smallest safe form.Production deployment, performance optimisation, bandwidth savings30–60% smaller
Beautify / FormatAdds indentation, line breaks and spacing. Expands compact code into a readable structure.Development, debugging, code review, learningLarger (adds whitespace back)

For a two-way workflow, use our JavaScript Formatter to beautify your scripts, then this JavaScript Minifier to ship them to production. Both tools use the same tokenizer, so a round-trip through them preserves the original script exactly.

JavaScript minification best practices

Here are a few things to keep in mind so your minified JS stays healthy in production:

  • Always keep the source file. Minified JS is very hard to edit by hand. Keep your original readable file in version control and minify as a build step.
  • Enable gzip or brotli on your server. Minification and gzip work best together — the minifier strips the content, the server compresses the remaining bytes.
  • Preserve license comments. If your script includes a license header, keep /*! ... */ comments so the license survives minification.
  • Use cache-busting filenames. Name your minified file script.min.js and add a content hash when serving so browsers do not serve stale code.
  • Do not edit the minified file directly. If you need to change something, edit the source and re-minify. Otherwise you will quickly end up with two divergent versions.
  • Test minified code before shipping. Especially if you rely on line breaks for ASI (automatic semicolon insertion). The semicolon safety option helps but is not a silver bullet.
  • Use a source map for debugging. Dedicated tools like Terser can emit a source map that points back to your original code, so browser dev tools still show readable lines.

Frequently asked questions

A JavaScript minifier (also called a JS compressor) removes whitespace, comments, line breaks and other unnecessary characters from your code. The resulting file behaves exactly the same when run but is 30–60% smaller, which means faster downloads and better page-speed scores.
No, if the code was valid to begin with. Minification only removes comments and unnecessary whitespace. The tool is careful to keep spaces where removing them would merge two tokens (like + +, = =, or two identifiers). It does not rename variables or transform logic.
Typically 30–50% smaller for well-formatted JavaScript, and up to 60% smaller for code with lots of comments and blank lines. The exact saving is shown in the statistics panel after you minify.
Yes. Comments that start with /*! are preserved by default — this is the widely used convention for license headers and legal notices. Regular comments are removed. You can toggle preservation on or off.
Yes. The tokenizer handles template literals, arrow functions, optional chaining (?.), nullish coalescing (??), async/await, generators, classes, private fields (#), and BigInt literals. JSX and TypeScript-only syntax are treated as plain expressions.
No. This minifier only removes comments and whitespace — it does not perform advanced compression like variable renaming, tree-shaking or dead-code elimination. For that, use a dedicated tool like Terser or esbuild. This tool focuses on safe, whitespace-level minification you can trust.
Absolutely. Everything runs in your browser using JavaScript. The code you paste never leaves your device — no server processing, no logging, no data storage.
Yes. Once the page loads, the minifier works without an internet connection. Bookmark it for offline work.
Yes. The tool is fully responsive and works on phones, tablets and desktops. The input and output panels stack vertically on small screens.
Yes, completely free. No signup, no watermark, no hidden charges. Minify as much JavaScript as you want for personal or commercial projects.
Minify compresses JS by removing whitespace and comments for smaller file size — perfect for production. Beautify (or format) expands JS with indentation and line breaks for readability — perfect for development and debugging. This page does minify; see our JavaScript Formatter tool for the reverse.