Minify JavaScript Online — Free JS Minifier

Minify JavaScript code instantly 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 — no code sent to any server.

Loading…
JavaScript Minification
Minify JavaScript online with Terser. Compress JS for production — instant browser processing, no uploads.

Features

Reduce the size of your JavaScript code by removing spaces, comments and unnecessary characters.

Minify

Reduce the size of your JavaScript code by removing spaces, comments and unnecessary characters.

Package used

Terser
v5.47.1

Terser is a modern JavaScript compressor that optimizes the size and performance of your code.

Basic example

Input code

function calculateTotal(items) { let total = 0; for (let i = 0; i < items.length; i++) { total += items[i].price; } return total; } const products = [ { name: 'Laptop', price: 999 }, { name: 'Mouse', price: 25 } ]; console.log('Total:', calculateTotal(products));

Minified code

function calculateTotal(e){let t=0;for(let o=0;o<e.length;o++)t+=e[o].price;return t}const products=[{name:"Laptop",price:999},{name:"Mouse",price:25}];console.log("Total:",calculateTotal(products));
JavaScript optimization guide

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, 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 on 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. Preserve Function Names and Preserve Class Names keep those bindings when something reads Function.prototype.name or CSS class strings. 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 — same engine, with a build step.

Minification options

ECMAScript Version
Defines the target ECMAScript version for minification (ES5, ES2015, ES2017, ES2020, ES2022)

Examples by ECMAScript version:

Original code (ES2022)
const data = { name: 'test' }; const { name } = data; console.log(name);
ES2022
const{name:data}=data;console.log(data)
ES5
var data={name:'test'};var name=data.name;console.log(name)
Compression Level
Controls the aggressiveness of compression (conservative, normal, aggressive)
ConservativeConservative - Minimal compression, safer
NormalNormal - Balance between size and compatibility
AggressiveAggressive - Maximum compression, may break some code

Compression examples:

Original code
function calculateTotal(items) { let total = 0; for (let i = 0; i < items.length; i++) { total += items[i].price; } return total; }
Conservative
function calculateTotal(items){let total=0;for(let i=0;i<items.length;i++)total+=items[i].price;return total}
Normal
function calculateTotal(t){let e=0;for(let l=0;l<t.length;l++)e+=t[l].price;return e}
Aggressive
function e(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].price;return t}
Preserve Class Names
Preserves CSS class names in string literals

Comparison with/without option:

Original code
element.className = 'my-class'; element.setAttribute('class', 'another-class');
With preserveClassNames: true
element.className='my-class';element.setAttribute('class','another-class')
With preserveClassNames: false
element.className='a';element.setAttribute('class','b')
Difference
CSS class names are preserved in strings
Preserve Function Names
Preserves function names for debugging

Comparison with/without option:

Original code
function myFunction() { return true; } const obj = { myMethod() { return false; } };
With preserveFunctionNames: true
function myFunction(){return!0}const obj={myMethod(){return!1}}
With preserveFunctionNames: false
function a(){return!0}const obj={b(){return!1}}
Difference
Function names are preserved for debugging
Remove Console
Removes all console.log, console.warn, etc. calls

Comparison with/without option:

Original code
console.log('Debug info'); console.warn('Warning message'); const result = calculateTotal(items); console.log('Result:', result); return result;
With removeConsole: true
const result=calculateTotal(items);return result
With removeConsole: false
console.log('Debug info');console.warn('Warning message');const result=calculateTotal(items);console.log('Result:',result);return result
Difference
All console.* calls are removed
Remove Debugger
Removes debugger statements from code

Comparison with/without option:

Original code
if (condition) { debugger; return true; } function test() { debugger; return false; }
With removeDebugger: true
if(condition)return!0;function test(){return!1}
With removeDebugger: false
if(condition){debugger;return!0}function test(){debugger;return!1}
Difference
Debugger statements are removed

See Beautify indentation options →

Learn more about this action →

Learn more about this action →

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.

Frequently Asked Questions — Minify

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, click the concat icon above the input editor or 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?

Click the concat icon in the input toolbar or drop multiple valid JavaScript files on the left editor. Reorder files in the modal, then click Concatenate &amp; 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

Shrink code and assets for production — minify JavaScript, CSS, HTML, JSON and XML before gzip or CDN deploy.

Explore other tool categories

Beautify

Make code readable with consistent indentation — beautify JavaScript, CSS, TypeScript, SCSS, LESS, Markdown, GraphQL, SQL, YAML and more in your browser.

Unminify

Expand minified or compressed code — unminify JavaScript, CSS, TypeScript, SCSS, LESS, SQL, YAML and other formats when debugging or reviewing.

Conversion

Transform data between JSON, YAML, XML and CSV locally — no server uploads.

CSS preprocessors

Compile SCSS or LESS to standard CSS in the browser — pair with beautify or minify for a full stylesheet workflow.

JSON Tools

Validate, format, diff and explore JSON payloads — complementary to minifiers and converters.

SVG Tools

Preview, optimize with SVGO, export Data URI, resize, beautify, convert to JSX and validate SVG — all in your browser.

DevOps & Infra

Terraform HCL format/validate/minify, Dockerfile format & lint, Docker Compose and .env validation.

CI/CD

GitHub Actions and GitLab CI — format YAML and check workflow/job structure in your browser.

Logs & observability

Line-oriented JSON/NDJSON and Nginx/Apache access logs — format, filter, validate, and CSV/TSV.

Kubernetes

Multi-doc manifests, structural validate, Ingress/Deployment starters, and Helm values formatting.

Networking / IP

CIDR, subnets, and IPv4/IPv6 helpers — in your browser.

Security & tokens

JWKS, X.509 certificates, and secrets scan — browser-local.

API & schemas

OpenAPI tools to format, validate, and lint your specs.

HTTP Tools

Paste-local cURL, HTTP messages, and URLs — format and inspect in your browser, never sent.

Encoding

Encode or decode Base64, URL components and HTML entities — client-side only.

Developer utilities

Timestamps, UUID, ULID, Nanoid, cron, passwords, regex, slugify, number bases, case, text diff, and chmod — all client-side.

Text & Markdown

Count words, build Markdown TOCs, and clean line lists — all in your browser.

AI & LLM

Token counting, pricing estimates, and context-window fit — 100% browser-local.

Test Data

Synthetic field values for fixtures and DB seed — reserved-range phone numbers first.

Serialization

Serialize and deserialize PHP data structures beside JSON workflows.