Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
EN – Language: English
Free, nothing uploaded

JavaScript Minifier
Smaller Code, Same Behaviour

A free online javascript minifier that keeps the functionality of your code, parses it, reduces the length of the names, removes unused parts, and returns a smaller file. To use, simply paste your code or drag and drop your files into the box. Press the "minfy" button. Copy the resulting code from the same tab as all processing occurs on that page.

  • FreePrice
  • Not neededAccount
  • NoneUploads
  • Every runChecked

JavaScript Minifier

Paste your code or drop your files — nothing is uploaded

or press Ctrl + Enter

Minified result

 
Original
—
Minified
—
Saved
—
Gzipped
—
Names shortened
—
Took
—

Ready. Paste your JavaScript, then press Minify or Beautify.

Your browser reads and rewrites your code here, in this tab. We upload nothing, store nothing and log nothing.

Run it on a test page before the live one

Keep a copy of your original code and try the result on a test page before you replace the live file. No automatic tool can see every way your site uses its code.

Link to this tool from your website

Copy the code below and paste it into your page. It adds a link to this free tool.

The short version

Inside the Denwix JavaScript Minifier: What It Removes

A JavaScript minifier removes all comments from your source code so that when you upload your code to your web server, the browser will download it faster. The minifier also removes indentation, and changes your long variable and function names into shorter ones. But your code continues to work exactly like it did before; changing the look of your code does not change how your code works.

The savings are real. The most what makes up a readable script are spaces and variable names, and both cost your users money each time they access your site. So if you can take a file that was 40 KB and get it down to 18 KB, it will arrive faster. This is true whether someone is accessing your site with a cell phone, a slow connection or from the other side of the planet.

This one parses your code rather than guessing at it. It builds a syntax tree and renames what is safe to rename. Then it deletes what nothing can reach, works out the arithmetic it can do in advance, and reads its own answer back to check it. The sections below explain each of those, including where it deliberately stops.

A minifier lives or dies on where statements really end. MDN's reference for JavaScript lexical grammar is the rulebook for that.

When to Minify JavaScript

Minify at the end, never at the start. You want the readable file in your editor and the small one on your server. So keep the original, publish the output, and never edit the minified copy by hand.

Diagram of a JavaScript function whose long names shrink to single letters while comments and the console call disappear
Lengthy variable names are swapped for short ones.

The most important thing to focus on is the scripts that load for each page. For example, a shared bundle that all visitors download should get much greater attention than a single script on a page no one visits.

JavaScript minifier with a small function pasted on the left and the packed code on the right, both boxes highlighted
Paste the code, get the packed copy.

What This JS Minifier Will Not Do

The program will only rename something if it can guarantee its safety. If you use a with statement, or directly call eval, your code can locate a name as a string during run-time. This is impossible for any parser to trace. When this occurs within a file, the renaming functionality turns off for the entire file. The tool explains why the renaming functionality was disabled, rather than allowing a broken renaming operation to occur in production.

JavaScript minifier with name shortening and console removal ticked, giving single-letter names and no log call
Shorter names and no console lines.

It will not rename your top-level names unless you tick the box. Pasted code is usually a classic script, where a top-level function becomes a property of window that another file may call by name. Inside a module or an IIFE nothing outside can reach those names, so there the switch is free bytes.

JavaScript minifier in beautify mode, turning one packed line into indented code, with the indent menu
Beautify mode makes packed code readable.

It won’t change global variables or the browser’s api. Window, Document and Console cannot be changed. Anything that was imported, exported, or not defined within the code you given, stays as is.

Source Maps in Brief

This tool does not write source maps yet, so a stack trace from renamed output will name functions by their short names. Need readable traces more than the last few bytes? Turn renaming off. The other passes still run, and you keep your original names.

Video guide

See the JavaScript Minifier at Work, Start to Finish

This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.

How it works

Minify JavaScript in Four Steps

No downloads, no registrations, no waiting lines. Everything is done within your web browser.

  • Add your code

    You may either paste a script into the editor or upload.js files using the upload tab. Both methods will produce the same result.

  • Choose what goes

    By default, comments will disappear, as will any unused code, renamed variables and constants that have been folded. If you’re going to ship your product, you may also remove console calls and debug statements.

  • Press minify

    The tool parses all files in a project, rewrites each file’s tree, and then reads what it wrote to the file to show you.

  • Copy or download

    Use the reduced script with the "copy" feature, or store it in your file system as "app.min.js". While doing so, the original version remains in the exact condition that you saved it.

Why this one

A JavaScript Minifier That Checks Its Own Work

Most tools hand you a file and hope. This one reads the result back before you ever see it.

  • It verifies every run

    Once it has been minified, it parses its output back into a parse tree. It then compares all names used in the code that are still available to be referenced, as well as the structure of the parse tree, to what you initially wrote. If there is a discrepancy between the two versions, it will let you know and give you the original version instead of remaining silent.

  • It understands real syntax

    Template literals, regexps (regular expressions), class fields (class properties), optional chaining, and BigInts will be read correctly. So, the character "/" will never be confused as being the beginning of a comment.

  • It respects semicolons

    Where JavaScript inserts a semicolon for you, the line break stays. Because that break costs one byte, keeping it is free as well as safer.

  • Nothing leaves your tab

    The script remains in this browser tab. No requests are made, no storage occurs, and no logging takes place, so, you can safely enter your private data into this space.

  • It keeps your licences

    Comments at the top of a file (the "banner") which begin with an exclamation point (!) or are marked as @license or @preserve remain in the file. Thus, you may use a minifier on your code as long as you give proper credit for the code.

  • You see the saving as it truly is

    The uncompressed size is shown in addition to the compressed size (gzip), since gzip is the format that is sent over the network to the visitor.

Good habits

Getting the Most From This JS Minifier

A few small habits keep a minified build predictable.

  • Keep the original. Always edit the readable file. So the minified copy stays something you generate, never something you maintain.
  • Minify last. Run it after your bundler and after your tests. Otherwise you are testing one file and shipping another.
  • Serve it gzipped. The process of minifying and compressing will reduce the size of your wire far below that of the actual file as it appears on your hard drive.
  • Drop console calls on purpose. The default setting for that switch is off, as a logging line may be crucial to operation. Only activate the switch once you are certain it does not.
  • Watch the verified badge. If you get an error message that states a run is not verified, then do not ship that file. Rather than shipping the file, submit the case to us and retain the original.
  • Mind your licence banners. Leave the banner on if your code has an attribution notice that needs to remain.
Avoid these

Mistakes That Break a Minified Build

Almost every "the minifier broke my site" story is one of these three.

  • Editing the minified file

    Any changes made there are gone when you rebuild. The solution to a problem with the build process will always be in the source.

  • Relying on function names

    Code that reads fn.name, or matches a class name as a string, breaks under any minifier that renames — including this one. Turn renaming off for those files, or stop depending on the name.

  • Minifying twice

    Running a previously minified file through a minifier does not save anything, and it will just make it difficult for someone to read the differences.

Questions

JavaScript Minifier FAQ

Will this JavaScript minifier break my code?

The tool will not make assumptions. It parses its own output against what you given: the name of the functions the code uses, and the structure of the syntax tree. The validation of this output will report any issues (e.g., corruption of a string, missing brackets, etc.) that would have occurred during the process of creating the new version of your source file. If a run doesn’t validate, the tool will return the exact copy of your original source file.

By what percentage will the Denwix minifier shrink my script?

Readable source usually drops 40 to 60 per cent, and the tool shows you the exact figure for your file. Heavily commented code with long names saves most; code that is already compact saves far less, because there is less left to take.

Does it rename variables like other tools?

Yes. It analyses every scope in the file and gives short names to locals, parameters and functions, shortest names to whatever appears most. Globals, browser APIs like window and document, imports and exports keep their names. If the file holds a `with` block or a direct eval, where code can look a name up as a string at runtime, renaming switches off and the tool tells you why.

Does my script ever reach a server?

No. The whole minifier runs inside your browser tab. There is no request, no storage and no log, so you can safely paste work you are not allowed to share.

Does the Denwix minifier take more than one file per run?

Yes. Open the upload tab and drop as many .js, .mjs or .cjs files as you like. The tool minifies each one separately, and you can download them one by one.

Can the Denwix minifier cope with classes, arrow functions and other modern syntax?

Yes. Modules, classes, private fields, template literals, optional chaining, nullish coalescing, BigInt and numeric separators are all read correctly. JSX and TypeScript are not JavaScript, though, so compile those first.

More free tools

More Denwix Tools Worth Opening Next

Every Denwix tool listed here runs locally, with no login and nothing uploaded.

  • SVG Compressor

    Shrink SVG files or pasted markup, and strip any scripts hiding inside them.

  • PNG to WebP Converter

    Convert a batch of images to a lighter format, keeping transparency intact.

  • Password Generator

    Build a strong random password or a passphrase you can actually say out loud.

Shrink your next script in seconds

Paste your code, press one button, and check the saving for yourself. Denwix neither receives nor keeps your script.

Prefer Denwix on GoogleReview Denwix on Google