Code Minifier

Minify JS, CSS, HTML and TypeScript

About Code Minifier

Code Minifier strips comments and collapses whitespace for JS, TS, CSS, and HTML entirely in your browser — nothing is uploaded to a server. For JS/TS and CSS, it's string-aware: it never touches the contents of quoted strings, template literals, or /regex/ literals, so a URL like https://example.com inside a string or a template literal containing // won't get corrupted. For HTML, it's a tag-aware scanner rather than a plain-text regex: it never mistakes a '<!--' or '-->' inside a quoted attribute value for a real comment delimiter, and it copies the contents of <script>, <style>, <pre>, and <textarea> through completely untouched instead of collapsing their whitespace. This is a lightweight minifier, not a full parser — it doesn't rename variables or eliminate dead code like tools such as Terser.

How to use Code Minifier

  1. 1Choose JS, TS, CSS, or HTML from the language buttons.
  2. 2Paste your code into the input box.
  3. 3Click 'Minify' to strip comments and collapse whitespace.
  4. 4Click 'Copy' to copy the result, or check the characters-saved count below.

Frequently Asked Questions

Is Code Minifier free to use?

Yes, it's completely free with no signup required.

Will minification break my code?

For JS, TS, and CSS, comment-stripping and whitespace-collapsing skip over string, template literal, and regex contents, so things like URLs inside strings are left intact. For HTML, comment-stripping only recognizes real '<!--' ... '-->' delimiters in actual markup position — an attribute value that happens to contain that text won't be misread as a comment and won't cause real content to be deleted — and <script>, <style>, <pre>, and <textarea> content is preserved exactly as written rather than whitespace-collapsed.

What languages does it support?

JavaScript, TypeScript, CSS, and HTML. There's no JSON-specific mode (use JSON Minifier for that) or support for other languages.

Does it store or upload my code?

No, everything runs locally in your browser; your code is never sent to a server.

Tips & Tricks

  • For JS/TS, whitespace inside strings, template literals, and regex literals is preserved exactly as written — only whitespace and comments in actual code get collapsed or removed.
  • For CSS, quoted string values (e.g. content: "a: b") are left untouched even though spacing and punctuation elsewhere gets tightened.
  • For HTML, <script>, <style>, <pre>, and <textarea> content is left byte-for-byte untouched — safe for a multi-line template literal, a CSS string with meaningful repeated spaces, or preformatted text.
  • Keep a copy of your original code before minifying, since there's no undo once you navigate away.