JavaScript Minifier
Conservatively compact JavaScript whitespace while retaining strings, comments, and line breaks. Runs entirely in your browser.
Why Minify JavaScript? — Reduce Bundle Size and Improve Time to Interactive
This tool performs conservative JavaScript whitespace compaction, not full parser-based minification. It collapses repeated spaces and tabs outside strings and comments while preserving line breaks.
What This Tool Preserves
- Quoted strings, comments, and line breaks are retained to avoid changing values or automatic semicolon insertion.
- Templates and ambiguous slash syntax (regular expressions or division) cause the original input to be returned unchanged.
- No variable renaming, syntax compression, tree shaking, or validation is performed.
JavaScript Bundle Size Impact on Performance
Transfer size, parsing, and execution can all affect performance. This compactor does not remove executable work, and a smaller source file does not guarantee a measurable speedup. Profile representative devices and network conditions.
JavaScript Optimization Best Practices
- Minify with production build tools — Use Terser (Webpack/Vite default), esbuild, or SWC for production builds
- Tree shaking — Remove unused exports with Webpack, Rollup, or Vite's tree-shaking
- Code splitting — Split bundles into smaller chunks loaded on demand with dynamic
import() - Lazy loading — Defer non-critical JavaScript with
asyncordeferattributes - Source maps — Generate .map files for debugging minified code in production
- Compression — Enable Brotli/gzip on your server for additional 60—80% transfer size reduction
Frequently Asked Questions
This tool only compacts repeated spaces and tabs outside protected strings and comments. It retains line breaks and returns templates or ambiguous slash syntax unchanged. For stronger minification, use a parser-based tool such as esbuild or Terser.
Input processing is local to this tool. Shared page features may make network requests, and enabled browser drafts may retain text locally. Avoid pasting credentials or confidential material.
Strings and line breaks are protected, but this is not a full JavaScript parser or a universal equivalence guarantee. Source-sensitive code such as Function.toString() can observe whitespace changes. Test output before production use; templates and ambiguous slash syntax are left unchanged.
Savings depend on repeated spaces and tabs and may be small or zero. Comments and line breaks are retained; templates and ambiguous slash syntax return unchanged. Measure the result instead of expecting a fixed percentage.
Minification focuses on reducing file size by removing unnecessary characters while keeping code functionally identical. Obfuscation intentionally makes code harder to read by renaming variables, restructuring logic, and adding dead code. This tool performs minification, not obfuscation.