Strip comments and whitespace from JavaScript safely. Nothing is renamed and broken output is never returned.
This removes comments and whitespace. It does not rename variables or drop dead code, because doing that correctly needs a full parser and a mistake means broken production code.
A single file or a snippet. Strings, template literals, regular expressions and comments are all recognised, so nothing inside them is touched.
Comments and indentation are usually a third of a source file. The before and after bytes are shown with the percentage saved.
The output is compiled before you ever see it. If it did not parse, you get your original back instead of something broken.
Because renaming safely needs a full parser and a scope analysis, and getting it slightly wrong produces code that looks fine and breaks in production. A tool that removes comments and whitespace correctly is more useful than one that mangles names and is right most of the time. For the full treatment, run esbuild or terser in your build.
Usually 30 to 40 percent on ordinary unminified source, and it depends almost entirely on how heavily commented the file is. A real minifier with renaming gets to 50 or 60 percent, and gzip on top of either matters more than the difference between them.
The output is compiled before you see it, so it cannot hand you something that fails to parse. What no syntax check can prove is that the meaning is unchanged, which is why the tool avoids every transformation where that is in doubt. Test the result, as you would with any build step.
Because JavaScript inserts semicolons at line ends in specific places, so removing a newline can change what the code means. After return, throw, break, continue and yield, and before ++ or --, the newline is part of the language and is kept.
Not as part of a build: your bundler already does it better. This is for the cases where there is no build, like a snippet going into a CMS field, an inline script in an email template, or a quick look at how much of a file is comments.
Yes. Optional chaining, nullish coalescing, class fields, private names, template literals, generators and async functions all tokenize correctly. It has been tested against real source files and the output re-imported to confirm it still loads.
You get told that the input is broken rather than the output. The input is checked first precisely so a pre-existing error in your file does not look like a bug in the minifier.
Yes, with our CSS minifier and HTML formatter. Both take the same care with strings and URLs that this one takes with regular expressions.
Minify or beautify CSS with strings and data URIs left intact, and see how much smaller it got.
Open ToolIndent messy markup or minify it, with void elements and pre blocks handled correctly.
Open ToolFree online JSON formatter and validator. Format, minify and validate JSON with syntax highlighting and instant error detection.
Open Tool