JavaScript Minifier — Reduce Bundle Size for Lighthouse Free

Free JavaScript Minifier — compress and minify JS code online instantly

Minify your JavaScript code instantly to reduce file size and improve performance. Remove whitespace, comments, and unnecessary characters with a single click. All processing runs locally in your browser with 100% privacy — no signup or upload required.

Quick Answer

How do I fix the 'Reduce unused JavaScript' Lighthouse warning?

The Lighthouse 'Reduce unused JavaScript' audit fires when JS files contain code that's never executed on that page. Minification alone won't fix it — you need tree-shaking (webpack/Rollup/Vite removes dead code at build time) or code splitting (load only the JS each page needs). Minify here to eliminate whitespace/comments; use your bundler for deeper size reduction.

Developer Tools★ Free forever✓ No account🔒 No upload📴 Works offlineUpdated April 28, 2026

Free JavaScript Minifier — Reduce JS Bundle Size Instantly

Paste your JavaScript code and get a minified version in seconds — whitespace removed, comments stripped, variable names shortened where safe. No upload, no account, runs entirely in your browser.

Browse all toolsBrowse more developer tools toolsBuilt by Achraf A., Full-Stack Developer · Morocco
Developer Utility

Free Online JavaScript Minifier

Instantly compress and optimize your JS code for faster load times, or format unreadable code into clean, perfectly indented scripts.

1. Input JavaScript Code
2. Output Result

Waiting for input...

About Our JavaScript Minifier

Our free online JavaScript Minifier & Formatter is an essential tool for developers aiming to optimize web performance. Minification is the process of stripping unnecessary characters from your source code , such as whitespace, newlines, and comments , without altering its functionality.

Conversely, if you have inherited a dense, unreadable script, our built-in formatting tool acts as a powerful code beautifier. It intelligently parses your JS and applies standard indentation, making the code clean and understandable in just one click.

How to Use the Tool

  1. Paste your code: Insert your raw JavaScript into the left text panel.
  2. Select action: Click Minify JS to compress the script, or Format JS to beautify it.
  3. Review output: The processed code will instantly appear in the right panel.
  4. Copy to clipboard: Click the "Copy Output" button to easily paste the result into your code editor or CMS.

Key Features

  • 100% Client-Side Privacy: All code processing happens securely in your browser. Nothing is ever saved to a server.
  • Advanced Compression: Intelligently strips out unneeded spaces, block comments, and line returns to cut file sizes.
  • Smart Formatting: Automatically restores nested block structures, string handling, and line indentations.

Frequently Asked Questions (FAQ)

What does a JavaScript minifier actually do?

A JavaScript minifier scans your code and removes everything that isn't strictly necessary for a machine to execute the script. This includes line breaks, indentations, and programmer comments. The logic of the code remains entirely untouched.

Why should I minify my JS code?

Smaller file sizes mean faster downloads. By minifying your scripts before deploying them to production, you significantly reduce the amount of data a user's browser needs to download, resulting in faster page loads and improved SEO rankings.

Will minifying break my application?

Our minifier uses standard safe regex parsing to strip space and comments. As long as your original code is syntactically valid (e.g., properly terminated with semicolons where required), the minified version will run exactly identically to the original.

Is my proprietary code safe?

Absolutely. Unlike backend-driven tools, this JS minifier operates entirely within your local browser environment. We do not transmit, log, or store the code you paste into the text areas.

Related Developer Tools

Was this tool helpful?

What is JavaScript Minifier/Formatter?

JavaScript minification is the process of removing all characters from source code that are not required for execution — whitespace, line breaks, comments, and long variable names — to reduce the file size that gets sent to the browser. A smaller JS file downloads faster, parses faster, and executes faster, which directly improves page load time and Core Web Vitals scores. For a typical web application, minification reduces JavaScript file sizes by 20–50%, and for code with many comments and long variable names, savings can exceed 70%. This directly translates to faster LCP, better performance scores, and a better user experience — especially on mobile connections.

Modern build tools like webpack, Vite, and esbuild handle minification automatically during production builds. But there are many situations where you need to minify JavaScript without a build pipeline: a quick script for a landing page, a CDN-hosted helper file, a browser extension script, or a snippet you want to inline in HTML. A browser-based minifier lets you paste the code and get the minified output immediately, without setting up a project or running a build command. It is also useful for understanding what a build tool's output looks like, or for quickly reducing a third-party script before including it in a project.

Minification is distinct from uglification (renaming variables to single letters) and bundling (combining multiple files into one). Basic minification removes whitespace and comments. Uglification additionally renames variables and functions to shorter names — more aggressive size reduction but makes the output harder to debug. Full bundling combines all imports into a single file to eliminate HTTP requests. This tool focuses on minification and optional variable renaming, covering the most common need without requiring a full build setup.

How to use JavaScript Minifier/Formatter
  1. 1

    Paste your JavaScript

    Paste the raw JavaScript source code you want to minify. Can be a complete module, a utility function, or any valid JS.

  2. 2

    Choose minification options

    Select whether to remove comments only, remove whitespace and comments, or also enable variable renaming (more aggressive, saves more space). Variable renaming is safe for inline scripts but may break code that relies on variable names at runtime.

  3. 3

    Minify and see the result

    The minified output appears instantly with the original and compressed sizes shown so you can see the reduction percentage.

  4. 4

    Copy or download

    Copy the minified code to clipboard for direct use, or download as a .min.js file. For production, store both the source and the .min.js so you can still debug from the original.

Key features and benefits
  • Reduces JavaScript file size by 20–70% depending on code structure and comment density
  • Runs entirely in the browser — your source code is never uploaded to a server
  • Shows original vs. minified size and percentage reduction
  • Supports optional variable renaming for maximum compression
  • Instant results — no build tool setup, no npm install required
  • Free, no account, no file size restrictions from server processing
  • Pairs with the CSS Minifier for a complete asset optimisation workflow
Common use cases

A developer adds a small utility script to a landing page and minifies it to reduce load time without setting up a webpack build for a single file.

A freelancer delivers a JS snippet to a client who will host it on a CDN — minifies it first to reduce the payload sent to every page visitor.

A developer inherits a codebase with un-minified scripts and minifies them to improve page speed scores before a performance audit.

A developer includes a third-party library that only provides an un-minified version and minifies it locally before adding it to the project.

A student learning web performance minifies their first project's JS to understand the size difference and verify their code still works after minification.

A developer builds a browser extension and minifies the background script to keep the extension package small for the Chrome Web Store submission.

Why browser-based works better

Server-based minifiers upload your source code to a remote server. For proprietary code, unreleased products, or code that contains internal logic you prefer not to share, in-browser minification keeps your code private.

No build tool setup required — for one-off minification tasks, installing webpack or esbuild to minify a single file is overkill. Paste and minify in 10 seconds.

The size reduction readout (original: 48KB → minified: 19KB, −60%) gives you an immediate signal of whether the minification was worth doing and where the gains are.

It pairs with the CSS Minifier so you can handle both JS and CSS asset optimisation in the same browser session without switching tools.

References and standards

JavaScript Minifier/Formatter FAQs

Quick answers about the workflow, privacy, and where this tool fits in a broader job.

Will minification break my JavaScript code?

Whitespace and comment removal is always safe. Variable renaming can break code that uses variable names at runtime (like eval(), dynamic property access via variable names, or code that reads its own source). Disable variable renaming if you are unsure.

What is the difference between minification and uglification?

Minification removes whitespace and comments. Uglification also renames variables and functions to short names (a, b, c) for additional size reduction. Both produce functionally identical code — the difference is how aggressively names are shortened.

Should I keep the original source file?

Always. Minified code is not human-readable or debuggable. Keep the original source in version control and serve only the minified version to users. Source maps can link the minified code back to the original for browser DevTools debugging.

How does this compare to running esbuild or terser?

Production build tools like esbuild, terser, or webpack's TerserPlugin are more comprehensive — they handle tree-shaking, bundling, and more advanced optimisations. This tool is for quick, one-off minification without a build pipeline.

Is my source code uploaded anywhere?

No. Minification runs entirely in your browser. Your code is never sent to any server.

Keep the workflow moving with nearby tools that solve the next likely step.

Built and maintained by

Achraf A.

Founder & developer — built and maintains every tool on this site

Last updated:

Tested in Chrome, Firefox, and Safari on desktop and mobile.


What a JS minifier actually removes — and what it can't touch

A JavaScript minifier strips whitespace, removes comments, shortens variable names, and collapses redundant syntax. The transformations that reliably reduce size: whitespace/newline removal (10–20% on average), comment stripping (varies widely — heavily commented code can save 5–15%), and identifier renaming (the big win for large files — renaming longDescriptiveVariableName to a throughout a file compounds quickly).

What can't be removed safely: eval() calls (variable references inside eval strings can't be renamed), and property names accessed via bracket notation like obj['name'] (the string might be dynamic). Real-world size reductions: React 18.2 (unminified 693 KB → minified 142 KB; gzipped 46 KB). Lodash 4.17 (542 KB → 72 KB minified; gzipped 25 KB).

Why you always need a source map for production

A source map is a JSON file that maps positions in your minified code back to the original source. Without it, a production error in your bug tracker shows: TypeError at a.b.c:1:4821 — useless for debugging. With a source map, the same error shows the original file name and line number.

Source maps can be served publicly (which exposes your original source code to anyone who looks in DevTools) or privately (served only to your error monitoring service via a token-protected endpoint). Sentry, Datadog, and Rollbar all support private source map uploads. For production code, private upload is the right choice — expose the map only to your error monitoring infrastructure, not to the public.

This tool vs. your build pipeline

This minifier is for one-off tasks: minifying a script you're embedding in an HTML email, compressing a small utility you're pasting into a third-party system, or quickly checking what a minified version looks like. For any project with a build step, use the bundler's built-in minifier — Vite uses esbuild, Next.js uses SWC, webpack can use Terser — all of which run automatically on npm run build and generate source maps as part of the output.

JS bundle size and Lighthouse — what actually matters

Lighthouse's JavaScript-related audits measure different things. Minification helps some — but tree-shaking and code splitting help more:

Lighthouse auditDoes minifying fix it?What actually fixes it
Minify JavaScriptYes — completelyRun this minifier and replace the file
Reduce unused JavaScriptPartially (removes comments only)Tree-shaking with webpack/Rollup/Vite; remove unused dependencies
Avoid enormous network payloadsYes — reduces file size 30–50%Minify + code-split; lazy-load non-critical JS
Reduce JavaScript execution timeNo — minification does not change logicProfile with Chrome DevTools; optimize loops, defer non-critical scripts
Eliminate render-blocking resourcesNo — that's about script placementMove <script> tags to bottom of <body> or use defer/async attribute
Legacy JavaScriptNo — that's about ES versionUse Babel/esbuild to transpile modern JS only when needed; drop IE11 support

A typical unminified JavaScript file compresses 30–50% from whitespace and comment removal alone. A React component tree minified with esbuild or Terser (which both do more than whitespace removal) typically shrinks 60–70%. Use this tool for quick one-off minification; integrate esbuild or Terser in your CI/CD pipeline for consistent production builds.

TheFreeAITools — JavaScript Minifier is a fully private, browser-based tool that minifies JavaScript code instantly, reducing file size by removing whitespace, comments, and unnecessary characters. Supports optional obfuscation, one-click copy, and download as a .js file. All processing runs locally on your device — your code never leaves your computer. The fastest free way to minify JavaScript in 2026, with no installs, no accounts, and no hidden limits.

☕ Support Us