Menu
PDF Tools
Image Tools
Converters & Utilities
Seller & Print Tools
Accounting & Business
Calculators
Text & Writing Tools
Developer & Web Tools
Creator & Social Tools
Browser Utilities & Games
Document & Design Makers
Text & Developer Tools
Exam & Form Tools

JavaScript Minifier

This tool minifies JavaScript by removing comments and extra white space. It keeps strings, template literals and regular expressions exactly as written.

How to use JavaScript Minifier online

  1. Paste the code. Type or paste your JavaScript.
  2. Read the result. The minified code appears with the bytes saved.
  3. Test it. Run the result before publishing.
  4. Copy it. Copy or save the result.

Why use this free JavaScript Minifier

  • Comments and spaces removed
  • Strings and templates kept
  • Regular expressions kept
  • Line breaks kept where needed
  • Bytes saved shown
  • Share by link

What a light minifier does

Full build tools shorten variable names, drop unused code and rewrite expressions. This tool does only the safe part: it removes comments and white space. That is quick, easy to trust, and works on a snippet or a file without a build step. The result runs the same as the original.

Careful with code

JavaScript is tricky to minify, because a slash can start a regular expression or mean divide, and a line break can end a statement. The tool reads the code as pieces. It keeps text in quotes and in template literals, and it keeps a regular expression when the slash comes where an expression can start. Line breaks that may end a statement are kept.

A worked example

The sample function with two comments, indentation and a string holding two spaces is 110 bytes. Minified it is 70 bytes, a saving of 36.4%: function add(a,b){return a+b;} / const s="a b";console.log(add(1,2),s);, where a slash marks a line break that is kept. The two spaces inside the string stay.

What to expect

The saving is smaller than with a full tool, since names are not shortened. Comments and indentation often make up a fifth to a third of hand-written code, so the saving can still be useful for small scripts. Comments that start with /*! are kept, which is where licence notices usually sit.

Test the result

Always run the minified code before you publish it. If you hit a problem, the most likely cause is a statement that relies on a line break, so add semicolons to the source. For large projects, use a build tool that can also remove unused code and shorten names, and keep this page for small jobs.

Using the tool

Change the text or any option of the JavaScript Minifier and the answer moves straight away. Use result as input to pass the answer to the next step.

JavaScript Minifier: frequently asked questions

Does it rename variables?
No. It removes comments and white space only.
Is a regular expression kept intact?
Yes, when the slash starts an expression.
Are line breaks removed?
Some are kept, so statements that rely on them still work.
What about licence comments?
Comments that start with /*! are kept.
Is it safe for all code?
Test the result. Odd code can still break.
Is the text I paste into the JavaScript Minifier uploaded?
No. The JavaScript Minifier works in your browser, and nothing is uploaded.
Can I copy the JavaScript Minifier result?
Save the JavaScript Minifier result as a text file, or copy it from the result box.

Related searches for JavaScript Minifier

  • JavaScript Minifier online
  • free JavaScript Minifier
  • JavaScript Minifier online free
  • JavaScript Minifier for mobile
  • JavaScript Minifier without sign up
  • JavaScript Minifier – Text & Writing Tools

JavaScript Minifier is a free online tool on MAITBOX, in the Text & Writing Tools group. It runs in your browser, so what you type is not sent to a server. It works on Android and iPhone, and on Windows, Mac and Linux, with no download and no account.

More tools in Text & Writing Tools →

Search tools