ToolNova

JavaScript Minifier

Reduce JavaScript file size by removing comments and extra whitespace.

This is a conservative minifier: it strips comments and whitespace but never renames variables or restructures code, so it won't achieve the same size reduction as a full build-tool minifier like Terser. It also does not attempt to distinguish regular-expression literals in every edge case.

How It Works

  1. 1Paste your JavaScript.
  2. 2It's minified automatically.
  3. 3See the size reduction and copy the result.

Features

  • String and template-literal aware comment stripping
  • Shows before/after size

Privacy

All processing happens instantly in your browser. Nothing you enter is ever sent anywhere.

About JavaScript Minifier

JavaScript minification reduces file size by removing content that doesn't affect how the code executes — comments and unnecessary whitespace, in this tool's case. More aggressive minifiers go further, renaming local variables to single letters and restructuring code to be more compact, but that requires fully parsing the JavaScript into an abstract syntax tree to know which identifiers are safe to rename without changing behavior.

Because JavaScript's syntax is context-sensitive — a / character can mean division or the start of a regular expression literal depending on what came before it, and string and template literals can contain characters that would otherwise look like comment delimiters — a minifier has to track that context carefully rather than just scanning for // and /* */ patterns naively. Getting this wrong is how a naive minifier can silently corrupt working code, for example by stripping something out of a string or misreading a regex as a comment.

This tool takes a deliberately conservative approach: it strips comments and collapses whitespace while staying aware of string, template literal, and, to the extent practical, regex context, but it never renames variables or restructures logic. That means it's safer to run on arbitrary code than a full build-tool minifier, at the cost of a smaller size reduction.

Frequently Asked Questions

Aggressive minification requires fully parsing JavaScript, which risks silently breaking unusual code. This tool trades some size reduction for safety.