Sign up free

JS Minifier – Minify JavaScript Online

Strip comments and whitespace from JavaScript without changing how it runs, and see how much you saved.

About JavaScript Minifier

This JS minifier is for sites without a build step: a script in a WordPress theme, a snippet on a landing page, a small widget you host yourself. Paste the code or open a .js file, and the minified version appears as you type, together with the size before and after. For a script embedded in an HTML page, the HTML Minifier minifies it along with the markup.

It works in a safe mode. Comments and whitespace are removed, except license comments that start with /*!, and a line break is kept wherever JavaScript's automatic semicolon insertion depends on it, so code written without semicolons still runs the same way. Variable names aren't shortened. That keeps function names readable in error messages, but it also means smaller savings than a full build tool gives. For renaming and dead-code removal, use esbuild or terser in your build. The JavaScript Formatter turns minified code back into something readable. Nothing is uploaded.

How to use JavaScript Minifier

  1. 1
    Paste your JavaScript

    Paste the code or open a .js file.

  2. 2
    Check the savings

    The JavaScript minifier updates live and shows the size before and after.

  3. 3
    Copy or download

    Copy the minified code or download it as a file.

Why use Cubfile for this

  • Safe mode

    Only comments and whitespace go, and the code itself isn't rewritten.

  • Aware of semicolon insertion

    Line breaks that automatic semicolon insertion relies on are kept.

  • License comments kept

    Comments written as /*! … */ stay in the file.

  • Savings shown

    See the size before and after before you copy.

FAQ

JavaScript Minifier: questions and answers

Will minified JavaScript still work?
That's what the safe mode is for. Only comments and whitespace are removed, and a line break stays wherever automatic semicolon insertion needs one. Test the page once after swapping files, as with any change.
Does the JavaScript minifier rename variables?
No. Renaming needs a full parser and is best left to a build tool such as esbuild or terser. You get smaller savings here, but names are never touched.
Can I minify code that doesn't use semicolons?
Yes. Where a line break ends a statement, the minifier keeps that line break instead of joining the lines, so the code runs the same.
Are license comments removed?
No. Comments written as /*! … */ are kept, so copyright notices stay in the file. All other comments are removed. The CSS Minifier treats license comments in stylesheets the same way.
Is my code uploaded when I minify JS here?
No. Minifying happens in your browser, with no sign-up and no daily limit.
Share JavaScript Minifier with a friendIt runs in any browser, and they can try it without signing up.

Related tools

HTML HTML FormatterIndent messy HTML so it’s easy to read.
JS JavaScript FormatterBeautify minified or messy JavaScript.
HEX Color ConverterConvert colors between HEX, RGB, HSL and CMYK, and check contrast.
CRON Cron Expression GeneratorBuild cron expressions and see the next run times in plain words.
CSS CSS FormatterTurn minified CSS into neat, readable rules.
CSS CSS MinifierMinify CSS to load faster.
HTML HTML MinifierShrink HTML by removing comments and extra whitespace.
HTTP HTTP Request TesterSend GET, POST and other requests to a public API and read the response.