Minify JavaScript Online — Free JS Minifier
Minify JavaScript code with our free online tool. Compress JS for production, reduce file size, or concatenate and minify multiple .js files in one pass. All processing happens in your browser, and no code is sent to any server.
Features
Reduce the size of your JavaScript code by removing spaces, comments and unnecessary characters.
Reduce the size of your JavaScript code by removing spaces, comments and unnecessary characters.
Package used
Terser is a modern JavaScript compressor that optimizes the size and performance of your code.
Basic example
Input code
Minified code
What JavaScript minification does
JavaScript minification rewrites source into a shorter form that still parses and runs the same way. It is not a zip archive: the output remains JavaScript, denser but not encoded. A minifier drops whitespace and comments, collapses equivalent syntax where it can prove the change is safe (true → !0, some if forms into &&), and shortens local identifiers. You still ship a .js file the browser executes as-is. On typical handwritten source, that often cuts 30–70% of the original bytes before gzip or Brotli.
Those extra bytes on the wire are a different layer. Minification shrinks what a transport compressor then sees; gzip and Brotli still matter after deploy. It also does not delete unused modules. That is tree shaking in a bundler, before Terser runs. And it is not obfuscation: names get short because they are local, not because control flow is hidden.
How FastMinify minifies JavaScript
This page runs Terser entirely in your browser. The pipeline is parse → compress → mangle → render; the toolbar maps onto those stages.
Parse builds an AST. Invalid JavaScript fails with a syntax error instead of emitting a broken file. Compress is the semantic pass: dead-branch elimination, constant folding, and optional stripping of console.* and debugger (Remove console / Remove debugger, both off by default). Compression Level changes how hard that pass works: Conservative keeps names and stays safer; Normal balances size; Aggressive enables stronger rewrites (including toplevel mangling) that can break code which depends on names. ECMAScript Version tells Terser which syntax it may emit. Choosing ES5 does not transpile arrow functions you already wrote.
Mangle (Normal and Aggressive) renames locals to short identifiers. Keep function names and Keep class names protect those bindings when code reads Function.prototype.name or a class name. Leave them on (or stay on Conservative) if you rely on eval or new Function. Render prints the AST with comments removed and the smallest legal separators.
The result is functionally identical unless aggressive compress plus mangling meets name-dependent code. Paste-and-minify is for a file or a few files; concatenation on this page merges files first, then runs the same pipeline. It is not a bundler. Production apps still belong in the build. For webpack, Vite, or CI, see the JavaScript minification guide, which uses the same engine with a build step.
Minification options
Examples by ECMAScript version:
Original code (ES2022)
ES2022
ES5
Compression examples:
Original code
Conservative
Normal
Aggressive
Comparison with/without option:
Original code
With preserveClassNames: true
With preserveClassNames: false
Difference
Comparison with/without option:
Original code
With preserveFunctionNames: true
With preserveFunctionNames: false
Difference
Comparison with/without option:
Original code
With removeConsole: true
With removeConsole: false
Difference
Comparison with/without option:
Original code
With removeDebugger: true
With removeDebugger: false
Difference
Concatenating JavaScript Files
On Minify JS, combine multiple JavaScript files in list order and minify the complete bundle with your current toolbar options. Processing stays entirely in your browser. This is especially useful for projects that don't use a bundler like Webpack or Rollup.
Minification FAQ
Everything about minification
Why minify JavaScript?
JavaScript minification reduces file sizes by removing whitespace, comments and shortening variable names. Typical savings are often 30% to 70% of the original bytes before gzip.
How does JavaScript minification work?
Our tool uses Terser, the industry-standard JavaScript compressor. It removes unnecessary characters while optionally mangling variable names. The minified code is functionally identical to the original.
Need to unminify JavaScript?
Use our dedicated JavaScript unminifier to restore readable formatting from minified code.
Need to beautify JavaScript?
Use our JavaScript beautifier to format code with consistent indentation.
Is my code processed securely?
All JavaScript processing happens entirely in your browser. No code is sent to any server.
Can I concatenate JavaScript files?
Yes. On Minify JS, select the concat icon above the input editor. You can also drop two or more .js, .mjs, or .cjs files on the input panel. Files are merged in list order, then the complete bundle is minified with your toolbar options.
How do I merge multiple JS files?
Select the concat icon in the input toolbar or drop multiple valid JavaScript files on the left editor. Reorder files in the modal, then select Concatenate & Minify.
Do comment separators between files stay after minify?
Not reliably. File markers are inserted before the complete bundle is minified, so // filename comments and extra spacing are typically removed.
Can I concatenate files on Beautify JS?
Not in the current release. Concatenation is available on Minify JS only.
Verify it yourself
FastMinify processes your input in the browser. Inspect the network panel or read our validation gate to confirm nothing leaves your device.
Minify
Minify JavaScript, CSS, HTML, JSON, XML, SVG and other formats to cut the bytes you ship, before gzip or a CDN.
Explore other tool categories
- Unminify
Make minified code readable again to debug or review it. Unminify JavaScript, CSS, TypeScript, SCSS, LESS, SQL, YAML and other formats.
- Conversion
Convert data between JSON, YAML, XML, CSV, TOML and other formats locally, with no upload to a server.
- Encoding
Encode or decode Base64, URLs, HTML entities and JWTs, and generate hashes and HMACs in your browser.
- Serialization
Serialize and deserialize PHP data structures beside JSON workflows.
- JSON Tools
Validate, format, repair, compare and explore JSON in your browser, alongside the JSON minifier and converters.
- SVG Tools
Preview, optimize with SVGO, export as a data URI, resize, beautify, convert to JSX and validate SVG in your browser.
- Beautify
Make code readable with consistent indentation. Beautify JavaScript, CSS, TypeScript, SCSS, LESS, Markdown, GraphQL, SQL, YAML and more in your browser.
- CSS preprocessors
Compile SCSS or LESS to standard CSS in your browser. Pair it with beautify or minify to handle a whole stylesheet.
- Color & CSS Tools
Check WCAG contrast, convert CSS colors and units, and generate shades, border-radius and box-shadow code in your browser.
- DevOps & Infra
Terraform HCL format/validate/minify, Dockerfile format & lint, Docker Compose and .env validation.
- CI/CD
Format GitHub Actions and GitLab CI YAML and check the structure of workflows and jobs in your browser.
- Logs & observability
Format, filter and validate JSON and NDJSON logs, and turn Nginx or Apache access logs into CSV or TSV.
- Kubernetes
Multi-doc manifests, structural validate, Ingress/Deployment starters, and Helm values formatting.
- Networking / IP
Subnet calculator, IP converter, range to CIDR, CIDR summarize and IP-in-subnet checks for IPv4 and IPv6, in your browser.
- Security & tokens
Inspect JWKS, verify JWTs, decode X.509 certificates, convert PEM and JWK, scan text for secrets and hash with bcrypt in your browser.
- API & schemas
Format, validate, lint and convert OpenAPI, JSON Schema and GraphQL SDL in your browser.
- HTTP Tools
Paste cURL commands, HTTP messages, URLs, HAR files and Cookie or Set-Cookie headers to format and inspect them. Nothing is sent.
- SEO / Web Tools
Generate meta tags, Open Graph, Twitter Card, robots.txt, sitemap.xml and JSON-LD in your browser. Previews come from your input, and your site is never fetched.
- Developer utilities
Timestamps, UUID, ULID, Nanoid, cron, passwords, regex, slugs, number bases, letter case, text diff, chmod and Lorem Ipsum, all in your browser.
- Text & Markdown
Count words, build Markdown tables of contents, turn CSV into Markdown tables and sort or deduplicate lines in your browser.
- AI & LLM
Count tokens, estimate API costs, check context-window fit, convert JSON to TOON and analyze prompts, all in your browser.
- Test Data
Dummy names, emails, phone numbers, addresses, dates, IBANs, card numbers and JSON, CSV or SQL rows for fixtures and database seeds. Everything is generated in your browser.
- Barcode labels
Draw Code 128, EAN-13 and UPC-A labels and static QR codes in your browser, then download PNG or SVG. This is not a GS1 lookup.