Upload a JavaScript (.JS) file and minify it to reduce file size for faster loading and easier distribution.
Minify JavaScript code instantly in your browser. XConvert's free JS Minifier removes whitespace, shortens variable names, eliminates dead code, and applies advanced optimizations to produce the smallest possible script — improving page load times and reducing bandwidth. Fully client-side, no data leaves your device.
Step 1 — Paste or Upload Your JavaScript
Open the XConvert JS Minifier and paste your formatted JavaScript into the input panel. You can also drag-and-drop a .js file directly onto the editor. The tool accepts any valid JavaScript, from a small utility function to a full application module.
Step 2 — Configure Minification Options
Review the available options in the toolbar. Key settings include Mangle (shorten local variable and function names to single characters), Compress (apply code transformations like dead-code elimination, constant folding, and boolean simplification), and Remove Console (strip console.log and other console statements). Each option can be toggled independently to balance size reduction against debuggability.
Step 3 — Click "Minify" Press the Minify button. The tool parses your JavaScript entirely inside your browser, applies the selected optimizations, and outputs compact code. A byte-count comparison shows exactly how much space you saved, along with the percentage reduction.
Step 4 — Copy or Download the Result
Click Copy to place the minified JavaScript on your clipboard, or click Download to save it as a .min.js file. The compressed output is ready for production deployment, CDN upload, or embedding in your build pipeline.
JavaScript minification is the process of reducing the size of a JavaScript file by removing characters and applying transformations that do not change the code's behavior. At its simplest level, minification strips whitespace, newlines, and comments. More advanced minifiers go further: they shorten local variable names (mangling), eliminate unreachable code (dead-code elimination), fold constant expressions at build time, simplify boolean logic, and inline small functions.
The size savings can be dramatic. A well-formatted, commented JavaScript file can shrink by 50–70 % after full minification. For web applications where JavaScript is often the largest asset type, this reduction directly improves page load times, reduces bandwidth costs, and improves Core Web Vitals scores like Largest Contentful Paint (LCP) and Total Blocking Time (TBT).
Minification is a standard step in modern front-end build pipelines. During development, you work with readable, well-commented code. Before deploying to production, you minify to optimize delivery. XConvert bridges these two states: use the JS Formatter while developing, then minify here when you are ready to ship. The tool is also invaluable for quick one-off minification tasks when you do not want to set up a full build pipeline.
| Feature | XConvert JS Minifier | Terser (CLI) | UglifyJS (CLI) | esbuild (CLI) |
|---|---|---|---|---|
| Cost | Free | Free | Free | Free |
| Installation | None (browser-based) | Required (Node.js) | Required (Node.js) | Required (Go binary) |
| Privacy | Client-side only | Local | Local | Local |
| Mangling | ✅ | ✅ | ✅ | ✅ |
| Dead-Code Elimination | ✅ | ✅ | ✅ | ✅ (tree-shaking) |
| Constant Folding | ✅ | ✅ | ✅ | ✅ |
| Console Removal | ✅ | ✅ | ✅ | Via plugin |
| ES6+ Support | ✅ | ✅ | ❌ (ES5 only) | ✅ |
| Size Comparison | ✅ (before & after) | Manual | Manual | Manual |
| Source Map Generation | ❌ | ✅ | ✅ | ✅ |
| Drag-and-Drop Upload | ✅ | ❌ | ❌ | ❌ |
| Works Offline | ✅ (after page load) | ✅ | ✅ | ✅ |
Production Deployment — Minify JavaScript as the final step before deploying to production. Smaller scripts mean faster downloads, quicker parsing, and better user experience, especially on mobile devices with limited processing power.
CDN Optimization — When uploading JavaScript to a Content Delivery Network, every kilobyte counts. Minified scripts reduce origin bandwidth and improve cache efficiency across edge locations worldwide.
Third-Party Script Distribution — If you distribute a JavaScript library, SDK, or embeddable widget, providing a .min.js version ensures consumers add minimal overhead to their pages. It is standard practice to ship both a readable and a minified version.
Reducing Bundle Size — Even after tree-shaking by a bundler like Webpack or Rollup, the output can benefit from minification. Mangling variable names and compressing expressions squeeze out additional bytes that bundlers leave behind.
Performance Audits — Lighthouse and PageSpeed Insights flag unminified JavaScript as a critical performance issue. Running your scripts through the minifier resolves these warnings and significantly improves your audit score.
Bookmarklet Creation — Bookmarklets must fit in a URL, so every character counts. Minifying the JavaScript before wrapping it in a javascript: URL produces the most compact bookmarklet possible.
XConvert's JS Minifier uses a client-side JavaScript engine based on a full AST (Abstract Syntax Tree) parser. When you click Minify, the tool parses the input into an AST, applies a series of optimization passes, and then emits the smallest possible code. The optimization passes include: whitespace and comment removal, identifier mangling (renaming local variables and function parameters to short names like a, b, c), dead-code elimination (removing if (false) { ... } blocks and unreachable code after return statements), constant folding (evaluating 1 + 2 to 3 at build time), boolean simplification (!0 instead of true), and sequence expression merging (combining consecutive statements with the comma operator where safe).
Mangling is the single most impactful optimization for size reduction. By replacing descriptive local variable names like userAccountBalance with single-character names like a, the minifier can save thousands of bytes in a typical application. Importantly, mangling only affects local identifiers — global variables, exported names, and property accesses are never renamed because doing so would break external references. You can also configure a "reserved" list to protect specific local names from mangling if needed.
All processing runs in the browser with no server communication. Your JavaScript — which may contain proprietary algorithms, API keys in test files, or unreleased feature logic — stays on your machine. The minifier supports modern ECMAScript syntax including arrow functions, template literals, destructuring, async/await, optional chaining, nullish coalescing, and class fields. For very large files (10 MB+), a CLI tool like Terser or esbuild may be faster, but for typical application modules the browser-based tool performs well. After minification, if you need to inspect or debug the result, paste it into the JS Formatter to restore readability.
Enable Mangling for Maximum Savings — Mangling (shortening variable names) typically provides the largest size reduction. Keep it enabled unless you have a specific reason to preserve variable names (e.g., code that uses eval() or relies on Function.name).
Remove Console Statements — Enable the "Remove Console" option to strip console.log, console.warn, console.error, and other console methods from production code. This reduces size and prevents debug output from appearing in users' browsers.
Test After Minifying — Always test your minified JavaScript in a browser before deploying. While the minifier preserves behavior, edge cases involving eval(), with, or dynamic property access by string name can be affected by mangling.
Combine with Gzip/Brotli — Minification and server-side compression are complementary. Minify first to remove redundant characters and shorten names, then let your web server apply gzip or Brotli for further savings. Together, they can reduce JavaScript delivery size by 80–90 %.
Keep Source Files Formatted — Never replace your source JavaScript with the minified version. Store readable, commented code in version control and generate the minified version as a build step. Use the JS Formatter to maintain readability in your source files.
Check the Size Comparison — Review the before-and-after byte counts displayed by the tool. If mangling is disabled and the reduction is modest, try enabling it. If the reduction is still small, the code may already be lean or the bulk of the size comes from string literals and data rather than identifiers.
When configured correctly, no. Minification preserves the code's behavior. The transformations (whitespace removal, mangling, dead-code elimination) are semantically safe. The one exception is code that relies on variable names at runtime (e.g., eval(), Function.name, or serializing function names) — disable mangling for such code.
No. XConvert's JS Minifier runs entirely in your browser. Your code stays on your device, making it safe for proprietary or sensitive scripts.
With mangling and compression enabled, typical reductions range from 50 % to 70 %. Without mangling (whitespace and comment removal only), expect 20–40 %. The exact savings depend on the code's structure, comment density, and variable name lengths.
Mangling is the process of renaming local variables and function parameters to shorter names (e.g., userAccountBalance → a). It is the single most effective size-reduction technique. Only local identifiers are mangled — globals, exports, and property names are never changed.
Tree-shaking is the process of eliminating unused exports from ES modules. It is typically performed by bundlers like Webpack, Rollup, or esbuild during the module-resolution phase. XConvert's minifier performs dead-code elimination (removing unreachable code within a file) but does not perform cross-module tree-shaking, as it processes a single file at a time.
Yes. The minifier fully supports modern ECMAScript syntax, including arrow functions, template literals, destructuring, default parameters, rest/spread operators, async/await, optional chaining (?.), nullish coalescing (??), and class fields.
The minifier expects standard JavaScript. TypeScript files must be compiled to JavaScript first (using tsc or a bundler) before minification. The minifier does not understand type annotations, interfaces, or other TypeScript-specific syntax.
No. Source map generation requires writing a mapping file alongside the minified output, which is better handled by CLI tools like Terser or esbuild integrated into your build pipeline. For quick one-off minification, source maps are typically not needed.
The JS Minifier removes whitespace, shortens names, and applies optimizations to reduce size, while the JS Formatter adds whitespace to improve readability. They are opposite operations — format for development, minify for production.
Yes. Once the page has loaded, all processing happens locally in your browser. You can disconnect from the internet and continue minifying JavaScript without any issues.