Minify JavaScript — strip comments, whitespace, optional name shortening. 40-70% smaller.
- Runs locally
- Category Format Converter
- Best for Turning pasted content or local files into a handoff-friendly format.
Minified output appears here.What this tool does
Free online JavaScript minifier. Paste any JS file (vanilla, ES modules, a JSON-P snippet, a single function you want to drop into an inline handler) and get a whitespace-stripped output 40-70% smaller than the input. This tool does WHITESPACE minify — it removes single- and multi-line comments, collapses runs of whitespace, strips trailing spaces, and (optionally) drops debugger statements. The tokenizer is JS-literal-aware: template literals (including ${expressions}), regex literals (so `/abc /g` does NOT get its whitespace collapsed inside the character class), single- and double-quoted strings, and division vs. regex are all disambiguated correctly — three places where naive "regex-based minifiers" silently corrupt your code. By design we do NOT do variable name shortening, dead code elimination, or AST-level rewrites — those are the territory of Terser / esbuild / SWC and require a real parser to be safe. Use this when you want a 30-second pre-deploy squeeze on a 200-line snippet, or to inline a JS handler into an HTML attribute without the 14 lines of indentation. For a production build of a real app, run Terser or esbuild locally instead. Live size diff (original / minified / saved %) prints under the output. 100% client-side — your unreleased scripts and internal logic never leave the tab. Pair with our CSS Minifier and HTML Minifier for a complete pre-deploy squeeze.
Tool details
- Input
- Text
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy + Download
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- No account required
- Open the page and use it; whether results survive refresh depends on the tool.
- Performance budget
- Initial JS <= 14 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Format Converter · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How JS Minifier fits into your work
Use it when the main problem is getting content from one practical format into another.
Conversion jobs
- Turning pasted content or local files into a handoff-friendly format.
- Previewing a conversion before you use it in a larger workflow.
- Cleaning small format mismatches without opening a full editor.
Conversion checks
- Try a small sample first when the source format is messy.
- Check character encoding, separators, and line endings after conversion.
- Keep the source until the converted output has been reviewed.
Good next steps
These links move the current task into a more complete workflow.
- 1 JSON Minifier Minify JSON into a compact single line, optionally sort object keys, and keep everything local. Open
- 2 CSS Minifier Minify CSS — strip comments, whitespace, shorten colors, merge selectors. 30-60% smaller. Open
- 3 HTML Minifier Minify HTML — strip comments, whitespace, optional attributes, inline CSS/JS. 40-60% smaller. Open
Real-world use cases
Inline a 14-line click handler into one HTML attribute
You wrote a 14-line analytics handler and need it inside an onclick attribute for a static landing page with no build step. Paste it, minify, and the comments plus indentation collapse to a single 380-char line that drops straight into the attribute. The regex inside your event filter stays byte-for-byte intact, so the click tracking still fires.
Shrink a pasted-in-Slack snippet before a CodePen demo
A teammate drops 300 lines of a tooltip widget in Slack and you want a tight version for a CodePen demo. Minifying cuts it by about 55%, from roughly 9 KB to 4 KB, so the embed loads faster and the demo iframe stops scrolling for ten seconds. Template literals in the markup builder survive untouched.
Compress a GTM custom HTML tag under the size budget
Google Tag Manager custom HTML tags get unwieldy fast, and large containers slow every page. You paste a 220-line consent script, strip comments and whitespace, and land 60% smaller, well under the container weight you were watching. Because no variables get renamed, the dataLayer.push calls and global names your other tags depend on stay exactly as written.
Squeeze a service-worker snippet without a bundler
A small project has one hand-written service-worker.js and no Vite or webpack. You want it lean for production but cannot risk a name-mangling bug breaking the cache-key logic. Whitespace minify gives you a safe 40-50% cut: the fetch-event regex and the cache version string come out identical, just without the 60 lines of comments.
Common pitfalls
Expecting Terser-level 80% cuts. This is whitespace-only minify and tops out around 40-70%; for the extra 30% run Terser locally, do not blame the tool for keeping your variable names.
Pasting a snippet that relies on a license comment at the top. Minify strips all comments, so a `/*! @license */` banner disappears; keep a separate copy of the banner and re-prepend it after minifying.
Assuming ASI (automatic semicolon insertion) safety. Whitespace minify keeps newlines that ASI may depend on only where needed, but code that relied on a comment-as-statement-separator (rare) can shift; always test the minified output once before shipping.
Privacy
This minifier runs 100% in your browser. The JavaScript you paste is tokenized and compressed in the tab with no network request, so unreleased scripts and internal logic never reach a server. Your source is never placed in the URL or shareable link, because code is typically too large and too sensitive for that; only the tool settings are shareable. Nothing is logged or stored.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- 555 Timer Calculator Astable f = 1.44/((R1+2R2)C) + monostable t = 1.1RC — pick R1, R2, C in Ω/kΩ and µF/nF, read frequency, duty cycle and pulse width — browser-only
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only