JavaScript minifier
With this JavaScript minifier, paste the code below: the tool removes comments and superfluous whitespace and shows how many bytes you save. Strings, template literals and regular expressions are left untouched; the result does the same as the original.
Source: Ecma International – ECMAScript Language Specification (§ 12.10 Automatic Semicolon Insertion). Updated: .
How it is calculated
Minifying JavaScript means removing everything execution does not need: comments, indentation, spaces and line breaks. The tool splits the code in your browser into strings, template literals, regular expressions, numbers, words and symbols and puts it back together with the least possible whitespace. The file loads faster; its behaviour does not change.
How it works
- Paste JavaScript into the field.
- Decide whether licence comments (/*! … */, @license, @preserve) should stay.
- Copy the result; the display shows the size before and after.
What happens when minifying
- Removed: line and block comments, indentation, repeated spaces, superfluous line breaks.
- Line breaks stay where they replace a semicolon (automatic semicolon insertion): after return, break, continue, throw, between statements without semicolons and before ++ and --. A space stays between two words or in + + and - -.
- Unchanged: strings, template literals (also nested) and regex literals – their content is never touched.
- Not renamed: variable and function names stay, which is why the result is always equivalent.
Limits
For the strongest shrinking (shortening names, removing dead code, restructuring code) use Terser or esbuild in your build. This tool is meant for quick, safe shrinking without any setup.
- Up to 2 million characters. TypeScript, JSX and other extensions are not JavaScript – compile them first.
- A regex literal directly after a closing parenthesis (for example if (x) /re/.test(y)) is read as a division; put braces or a semicolon there. The syntax is not checked.
Privacy
The code never leaves your browser. For stylesheets there is minify CSS; next steps: format HTML or test a regex.
Frequently asked questions
How can I minify JavaScript?
Paste the JavaScript into the field: the tool removes comments and whitespace and shows the saving. Copy the result into your file.
Does minifying change the behaviour of the code?
No. The tool only removes comments and whitespace and leaves strings, template literals and regular expressions unchanged. Line breaks stay where they replace a semicolon.
Are variable names shortened?
No. This tool does not rename anything. For the strongest shrinking use Terser or esbuild in your build.
How much does minifying save?
For commented, indented files often 20 to 50 percent. On top of that the server compresses with gzip or Brotli; both together make sense.
Can I make minified code readable again?
This tool only goes one way. For indenting code, editors or a code formatter are suitable.
Is my code uploaded?
No. Everything runs locally in your browser.
Sources and legal basis
- Ecma International – ECMAScript Language Specification (§ 12.10 Automatic Semicolon Insertion)
- MDN – Lexical grammar (Zeichenketten, Template-Literale, Regex-Literale, Kommentare)
- MDN – Automatic semicolon insertion (Fallstricke: return, ++, --)
As of: · Editorial policy
Related tools
- CSS minifier: minify, format and inline CSS into HTMLCSS minifier and formatter, plus a CSS inliner for HTML email: safe transformations, errors with line numbers, all in your browser with no upload. Free.
- HTML formatterHTML formatter: indent source code to make it readable, or minify it to a single line, with warnings about unclosed tags. Runs locally in your browser.
- JSON formatter, validator and minifierValidate JSON against RFC 8259 with the exact line, column and a plain-English explanation. Beautify or minify, sort keys, copy. Runs locally in your browser.
- Regex TesterTest JavaScript regular expressions live: matches highlighted, capture groups in a table, every part of the pattern explained. Free, nothing uploaded.
- SQL formatter (format SQL online)SQL formatter for readable queries: uppercase keywords, indentation, columns and conditions on separate lines. Also minifies SQL. Runs locally in your browser.
- XML formatterXML formatter: beautify, minify and validate with line and column of the error, tree view, XPath query and XML to JSON. In your browser, no upload.
- What is my IP address?What is my IP? See your public IPv4 or IPv6 address at once, plus approximate location, internet provider and browser details. Free, never stored.
- EU VAT Number Checker (Format and Check Digit)Check the format and check digit of an EU VAT number for all 27 member states and Northern Ireland (XI). Runs locally, with links to VIES for validation.
- JSON-LD GeneratorJSON-LD generator for Schema.org: fill in an article, FAQ, product, local business or organization and copy ready-to-use code with a built-in error check.