</> Online Utilitiesdev.conversiontools.online

JS Minifier — compress JavaScript, remove comments & dead weight

Paste JavaScript and get a smaller file, live: comments and wasted whitespace removed, license banners kept, console and debugger statements stripped on request — with the exact byte saving shown before you ship it. Strings, template literals and regular expressions are never touched.

What to remove

License banners (/*! … */ or comments containing @license, @preserve or @copyright) survive when “Keep license banners” is on. Console removal only strips console.* calls that stand as their own statement — a console reference used inside an expression is left alone. This minifier never renames variables, so the output behaves exactly like the input.

Send minified JavaScript to…

Carry the current result into the next step of your workflow. Short results travel in the link itself — nothing is uploaded.

Start from an example

One click loads the code and the option set that suits it — the minified result and its saving appear immediately.

Your session

Versions from this visit, kept only in this tab's memory — step back and forth, pin the ones you want to keep handy, and restore any of them with one click. Nothing here is stored or sent anywhere.

Recent versions

    No versions yet this session — paste JavaScript or load an example and they will appear here.

    Pinned versions

      No pinned versions yet — pin one above to keep its minified output handy.

      Your tools

      Tools you have actually opened this session, plus any you pin as favorites. The lists live in this browser session only.

      Recently used

        No other tools opened yet this session — tools you visit will appear here.

        Favorite tools

          No favorites yet — pin a tool below.

          All encoding, conversion & developer tools

            How to minify JavaScript online

            1. Paste your JavaScript — a full file or any snippet — into the input box. The minified result and byte counts update live.
            2. Toggle what to remove: comments and whitespace always; license banners kept by default; console calls and debugger statements stripped only if you ask.
            3. Check the saving, then copy the result or download it as a .js file. Keep your readable original as the copy you edit.

            Worked example

            Input (278 bytes): // Shopping cart total function calculateTotal(items) { let total = 0; for (const item of items) { total += item.price * item.qty; } // Apply a 10% discount over $100 if (total > 100) { total = total * 0.9; } console.log("Total:", total); return total; } Output (168 bytes, 110 bytes saved — 39.6% smaller): function calculateTotal(items){let total=0;for(const item of items){total+=item.price*item.qty} if(total>100){total=total*0.9} console.log("Total:",total);return total}

            Both versions run identically. The comments and every indentation space are gone; the line breaks that remain sit where joining lines could change meaning — this minifier keeps a break after a closing brace rather than guess whether it ends a block or an object literal. The console.log call stays because console removal is off by default.

            What each option removes

            OptionRemovesNever removes
            Comments// … and /* … */ commentsAnything that looks like a comment inside a string, template literal or regex
            WhitespaceIndentation, line breaks, spaces around operators and punctuationA line break after return, or one acting as a semicolon (ASI); the space in i + +2 that keeps it from becoming i++2
            Keep license banners— (a keep switch, on by default)Comments starting /*! or containing @license, @preserve, @copyright
            Remove console.*console.log, console.warn… calls standing as their own statementA console reference used inside an expression, e.g. var x = console.log
            Remove debuggerdebugger; statementsThe word “debugger” inside strings or property names

            Safe minification vs. mangling

            There are two levels of JavaScript minification. This tool does the safe level: tokenize the code properly, delete comments and whitespace, and stop. Build tools such as Terser and UglifyJS add a second level — renaming local variables to single letters, dropping unreachable code, folding constants. That squeezes further, but it can surprise code that inspects function names or uses eval. For a pasted snippet, a single file, or an inline script, the safe level is the right default; reach for a build tool when you ship a whole bundle.

            Minify, then compress

            Minification and transfer compression do different jobs. Minification deletes bytes outright — comments and indentation are gone before the file leaves the disk. gzip or Brotli then squeezes the patterns that remain, and a smaller file also parses faster. Run this tool first, then let your server compress the result.

            What to do with your minified JavaScript next

            Minified output is a publishing artifact, not a working file. Save it alongside your readable source, spot-check the page or app in a browser, and when the script belongs inside a page, minify the whole document with the HTML Minifier; to hand the code to an API or config file, run it through the JSON Formatter or Base64 Encoder/Decoder. The “Send minified JavaScript to…” bar above carries the current result into each of those tools for you — and code those tools send back arrives here ready to minify.

            Frequently asked questions

            What is JavaScript minification?

            JavaScript minification removes everything the engine does not need to run the code: comments, indentation, line breaks and extra spaces. The logic, names and behaviour stay identical — only the file gets smaller, so it downloads, parses and starts faster. Build-tool minifiers go further and also rename local variables; this tool deliberately does not.

            Does minified JavaScript behave exactly the same?

            Yes. This minifier is a tokenizer, not a text replacer: it understands strings, template literals, regular expressions and comments, so it never edits the inside of a string or mistakes a division sign for a regex. It also keeps a line break wherever removing it could change meaning — after return, and where automatic semicolon insertion (ASI) is load-bearing in code written without semicolons. Always keep your readable original as the source you edit.

            What exactly does this JS minifier remove?

            You choose: line and block comments, collapsed whitespace and line breaks, console.* calls in statement position, and debugger statements. License banners (comments starting /*! or containing @license, @preserve or @copyright) can be kept even when other comments are removed. The stats panel shows the exact byte saving and how many of each item was removed.

            Will it break my strings, template literals or regular expressions?

            No. A URL like "https://example.com" is never mistaken for a comment, a /* inside a string stays put, template literals are copied verbatim including their ${ } expressions, and the tokenizer tells a regex literal (/[0-9]+/) apart from a division operator (a / b) by looking at what came before it — the same distinction the JavaScript parser itself makes.

            Does this tool rename (mangle) variables?

            No — and that is deliberate. Renaming variables, dropping dead code and reordering statements (the extra steps build tools like Terser or UglifyJS perform) can change behaviour in code that relies on function names, eval, or property access. This tool only removes comments and whitespace, which is always safe, so it is ideal for quick one-off files, snippets and inline scripts. Use a build-tool minifier with mangling for large production bundles.

            What happens to license comments?

            With “Keep license banners” switched on (the default), comments that begin with /*! or contain @license, @preserve or @copyright survive minification while every other comment is removed. Library licenses usually require that notice to stay in distributed files, so keep it on for third-party code.

            Should I remove console.log and debugger statements?

            For production code, usually yes: leftover console calls add noise and a forgotten debugger statement pauses execution whenever DevTools is open. This tool only removes console.* calls that stand as their own statement — a console reference used inside an expression is left untouched. The options are off by default, and the count of removed calls is shown in the stats, so nothing disappears silently.

            Does it handle code written without semicolons?

            Yes. Where a line break is doing the work of a semicolon (automatic semicolon insertion), the minifier keeps that line break instead of joining the lines — so let a = 1 on one line and let b = 2 on the next stay two statements. It also preserves the break after return, where JavaScript forbids a value on the next line from being returned.

            Is my JavaScript uploaded or saved?

            No. Minification happens entirely in your browser as you type; nothing is uploaded, stored or tracked. Session history lives only in this tab's memory and disappears when you close it.

            Related encoding & conversion tools

            About this tool

            The JS Minifier is one of the free utilities in the Online Utilities Suite at dev.conversiontools.online. Every tool runs entirely in your browser — your code is never uploaded, stored or tracked — so minification is instant and private, and the byte counts you see are measured on the exact text in the box, in UTF-8 bytes.

            Privacy

            This page processes everything locally in your browser: no account, no uploads, and nothing you paste is stored or sent to a server. Advertising on this site is served by Google AdSense, which may use cookies to personalize ads; you can opt out of personalized advertising in your Google ad settings.