whatisgithub

What is uglifyjs?

mishoo/uglifyjs — explained in plain English

Analysis updated 2026-06-24

13,393JavaScriptAudience · developerComplexity · 2/5Setup · easy

In one sentence

UglifyJS is a JavaScript toolkit that compresses source code into smaller files for faster web page loading, with a command-line tool, JavaScript API, source map support, and a beautifier.

Mindmap

mindmap
  root((UglifyJS))
    What it does
      Minification
      Mangling
      Beautification
    Features
      Source maps
      Dead code removal
      CLI and API
    Tech
      JavaScript
      Node.js
      npm
    Use cases
      Web deploy
      Build pipelines
      Code obfuscation
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Shrink JavaScript files before deploying a website to speed up load times

USE CASE 2

Obfuscate source code by shortening variable and function names using the mangler

USE CASE 3

Generate source maps so compressed code can be debugged in the browser's devtools

USE CASE 4

Integrate minification into a build pipeline via the JavaScript API

What is it built with?

JavaScriptNode.jsnpm

How does it compare?

mishoo/uglifyjsraspberrypifoundation/blocklyrwaldron/johnny-five
Stars13,39313,40413,404
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasymoderatemoderate
Complexity2/53/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

So what is it?

UglifyJS is a toolkit for processing JavaScript files. Its main use is minification: taking readable JavaScript source code and compressing it into a much smaller file that works the same way but takes less time to download. Smaller files matter because websites typically load JavaScript from a server, and large files slow that down. The toolkit does several things. The parser reads JavaScript and builds an internal representation of the code. The compressor rewrites that representation to be more efficient, removing dead code, collapsing expressions, and applying various logic transformations. The mangler shortens variable and function names from descriptive words to single characters, which saves space without changing behavior. A beautifier does the opposite: it takes compressed or unformatted code and makes it readable again with proper indentation. Both a command-line tool and a JavaScript API are provided. The command line takes one or more input files, runs the selected steps, and writes output to a file or to standard output. You can control exactly which features to apply with flags: compression, mangling, property name mangling, and beautification all have their own switches and sub-options. Source maps are supported, which allow browsers to map the compressed code back to the original source for debugging. The tool supports most JavaScript syntax, including modern ECMAScript features. For very new or exotic syntax it recommends running a tool like Babel first to convert the code to something UglifyJS understands. The v3 API is not backwards compatible with the older v2 series. Installation is a single npm command, either globally to use it from the terminal or locally to use it inside a project. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Show me how to use UglifyJS from the command line to compress and mangle app.js and output app.min.js with a source map
Prompt 2
Write a Node.js script that uses the UglifyJS JavaScript API to compress multiple input files and merge them into one minified bundle
Prompt 3
How do I configure UglifyJS to remove all console.log statements from my code during the compress step?
Prompt 4
What UglifyJS flags do I need to enable property name mangling while keeping my public API intact?
Prompt 5
How do I use UglifyJS to beautify a minified file back into readable, indented code?

Frequently asked questions

What is uglifyjs?

UglifyJS is a JavaScript toolkit that compresses source code into smaller files for faster web page loading, with a command-line tool, JavaScript API, source map support, and a beautifier.

What language is uglifyjs written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js, npm.

How hard is uglifyjs to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is uglifyjs for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.