JavaScript मिनिफायर
Minify JavaScript by removing comments and whitespace आपके ब्राउज़र में. Free, online, अपलोड नहीं, fully पूरी तरह से निजी.
Local processingWhat is JavaScript मिनिफायर?
A JavaScript minifier compresses JS source by removing comments, whitespace, and redundant tokens without changing runtime behavior. Minified scripts ship fewer bytes, improving load time and parse cost. This tool performs safe, conservative minification — it strips comments and whitespace but does not rename variables or rewrite control flow, avoiding the risk of breaking code that relies on a full AST analysis it does not perform.
How It Works
The minifier tokenizes the source (strings, regex literals, comments, punctuation, identifiers) and re-emits a compact form. Comments (// and /* */) are dropped. Whitespace is removed where it is not significant — between tokens that the parser can separate without ambiguity. String and regex literals are preserved verbatim to avoid breaking their content. Trailing semicolons at block ends are kept where ASI (automatic semicolon insertion) would be unsafe.
Common Use Cases
- Preparing production scripts — minify before deploy to reduce bundle size
- Inlining small scripts — compress a snippet for embedding in HTML
- Optimizing third-party snippets — shrink analytics or widget code before serving
- Reducing parse cost — smaller scripts parse faster, improving time-to-interactive
Technical Details
Approach: token-based minification (no AST rewrite, no variable renaming). Removed: comments, insignificant whitespace. Preserved: string/regex literal contents, required semicolons, all identifiers. Safe minification avoids ASI hazards by keeping semicolons where removal could change semantics. Typical reduction: 30-50%. For maximum compression (mangling, dead-code elimination), use a full bundler like esbuild or terser.
How to Use
Enter your input above. The result updates automatically. Use the copy button to copy the result.
Privacy
All processing happens in your browser. Your data is never uploaded to any server.
FAQ
Is my JavaScript uploaded?
No. Minification happens locally in your browser. Your code never leaves your device.
Does it rename variables?
No. This minifier removes comments and whitespace but preserves variable names for safety without a full AST parser.
Does it remove comments?
Yes. Both single-line (//) and multi-line (/* */) comments are stripped. String and regex literal contents are preserved verbatim so commented-out code inside strings is not affected. Trailing semicolons are kept where removal could trigger ASI hazards.