Free Code Minifier & Beautifier

Minify (strip comments and whitespace) or beautify (re-indent) HTML, CSS, or JavaScript.

Output

Why a slash isn't always a comment

Minification sounds simple — strip comments, collapse whitespace — until you hit JavaScript's most famously ambiguous character: /. It can open a // line comment, a /* */ block comment, a division operator, or the start of a /regex/ literal, and telling them apart requires actually tracking what came before it. a / b is division; return /abc/.test(x) is a regular expression — the only way to know which is to look at the previous meaningful token, which is exactly what this tool's tokenizer does before deciding whether to touch a slash at all. Get that disambiguation wrong and a minifier can silently corrupt working code by treating a regex as the start of a comment.

Strings and template literals face a related trap: a URL like "http://example.com" contains // that must never be read as a comment, and a template literal such as `Total: ${price}` can itself contain nested strings, comments, and even other template literals inside its ${...} interpolation. This tool's minifier walks that structure recursively rather than scanning character-by-character for comment markers, so nested cases stay intact.

What minifying actually buys you

Stripping comments and whitespace mainly reduces transfer size and browser parse time — it does not make already-running JavaScript execute meaningfully faster, since the engine still runs the same logic either way. For an actual production build, a dedicated bundler (which can also rename local variables and tree-shake unused code) will typically shrink output further than whitespace/comment stripping alone.

Frequently Asked Questions

Is minify mode safe for real code, not just simple snippets?

It's built to be safe rather than aggressive: it only strips comments and collapses whitespace — it never renames variables or restructures logic. It correctly distinguishes strings, template literals, and regular expressions from comments (so it won't mangle a URL containing "//" or a regex containing "/"). For very obscure edge cases — like a string holding a stray curly brace immediately followed by a nested template literal — always sanity-check the output before shipping it. For a production build pipeline, a dedicated bundler/minifier is still the right tool.

Does beautify fully reformat my code like a linter would?

It re-indents based on brace and tag nesting, which makes minified or poorly-formatted code readable again. It doesn't apply a full style guide (line-wrapping, operator spacing, quote style) the way a tool like Prettier does.

What happens to comments in HTML's <script> and <style> tags?

In HTML mode, the content inside <pre>, <script>, <style>, and <textarea> tags is preserved exactly as-is — only HTML comments and whitespace between other tags are touched, so embedded JS/CSS isn't affected by HTML-mode processing.

Why can't a minifier just delete every "//" it finds?

Because "//" isn't always a comment — it appears literally inside strings (URLs like "http://…"), and a bare "/" can also mean division or open a regular expression. Blindly stripping on sight would corrupt any code containing those patterns, so a correct minifier has to track context, not just match characters.

Does minifying make my code run faster, or just download faster?

Mostly the latter. Removing comments and whitespace shrinks the file (faster download) and gives the parser less text to read (faster parse), but it doesn't change the underlying logic the engine executes — so actual runtime execution speed is essentially unaffected.

Is my code sent anywhere?

No. Everything runs entirely in your browser. Nothing is uploaded or stored.