Toolvito

Calculates on this device. File exports run online.

Code Minifier

Paste code or open a file, and the page makes it smaller by removing comments, line breaks and spaces it does not need. It can also do the reverse and lay minified code out so you can read it. Everything happens in your browser.

Enter your values

Removes comments, line breaks and spaces that the code does not need. Strings, regular expressions and the content of <pre> stay exactly as they are.

Your values

Find out from the code looks at how the code starts. If it guesses wrong, choose the language.

Up to 2,000,000 characters. The code stays on your device.

More options

Comments that start with /*! usually hold a licence that must stay with the code.

Conditional comments for old Internet Explorer (<!--[if …]>) are always kept in HTML.

In MySQL a # starts a comment to the end of the line; in PostgreSQL # is an operator. When this is not ticked, a line with # keeps its line break, so the result works either way.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose the button below them.

Minify on the server, or check and convert SQL

Task
Minify on the server and download (with gzip sizes)

The code in the box above is minified again by other minifiers (rjsmin for JavaScript, rcssmin for CSS, minify-html for HTML, lxml for XML and SVG) and offered as a file, with its size before and after gzip compression. For HTML the server can also leave out end tags that HTML allows to be left out.

Untick to leave out end tags that HTML allows to be left out: the file gets smaller and works the same in browsers.

The calculator above works on your device. When you run a task in this section, Toolvito receives the values and result you submit to make the file or run the check. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

How to minify code

  1. Paste your code into the box, or press Or open a code file from your device.
  2. Leave Language on Find out from the code, or choose JavaScript, CSS, HTML, JSON, XML or SVG, or SQL.
  3. Press Minify. The minified code is shown with its size before and after.
  4. Press Copy or Download to use the result.
  5. To read minified code, choose Beautify and press Beautify.

What is removed, and what is kept

  • JavaScript: comments and spaces. Strings, template literals and regular expressions are copied as they are. A line break stays where removing it could change the meaning (automatic semicolon insertion), and a + + or - - stays apart. Comments that start with /*! (licences) are kept unless you untick that.
  • CSS: comments and spaces, the last ; of each rule and the space before !important. A space that is part of a selector, as in a :hover, is kept.
  • HTML: comments and the spaces the browser would not show. One space stays between inline elements such as <b> and <i>. The content of <pre> and <textarea> is not changed; CSS and JavaScript inside <style> and <script> are minified too.
  • JSON: every space outside strings. Numbers are copied exactly as written, so 2.50 stays 2.50.
  • XML and SVG: comments and the spaces between elements. Elements that hold text, and anything under xml:space="preserve", keep their spaces.
  • SQL: comments (-- and /* */) and spaces. Quoted text and $$ function bodies stay as they are. In MySQL # also starts a comment: tick it under More options.

Worked example

A JavaScript function add(a, b) written on four lines with a comment line, 64 bytes in all, becomes function add(a,b){return a+b;}: 30 bytes, 53.1% smaller. Beautify lays it out again on three lines; the comment is gone for good.

Limits you should know

  • Names of variables and functions are not shortened, and code is not rearranged. A bundler such as esbuild or terser does that with your whole program in view; the result here is larger, but always means the same.
  • The page reads the language with small rules, not a full parser: code with a syntax error is minified as far as it can be read, and a text that is not closed (a string, a comment) is reported with its line and column.
  • JSX, TypeScript, PHP, Java and SCSS are not supported.
  • Find out from the code looks at how the code starts. When it guesses wrong, choose the language.

Privacy

Minify and Beautify work in your browser; your code is not uploaded. Only when you use the box below is the code in the box sent to the Toolvito server to minify it there or to check and convert SQL. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

Related tools