There is no standard way to ask npm to get the minified version of a library. Some developers will produce packages that contain both minified and unminified versions (that's what I've done for one of my projects, which is web-only but can be installed through npm) or will create a package that contains an unminified version and another package that contains the minified version. This is done on a case by case basis, varies from package to package, and has to be determined by looking at a project's documentation.

If a developer has not cared to provide a minified code base through npm then you'll have to perform the minification yourself or get the "official" minified code through some other means.

Answer from Louis on Stack Overflow
🌐
npm
npmjs.com › package › unminify
unminify - npm
Latest version: 2.0.0, last published: 4 years ago. Start using unminify in your project by running `npm i unminify`. There are 1 other projects in the npm registry using unminify.
      » npm install unminify
    
Published   May 20, 2022
Version   2.0.0
Author   Kevin Gibbons
🌐
Unminify
unminify.com
Unminify JS, CSS, HTML, XML and JSON Code
This unminifying tool will take minified code and expand it so it is easier for humans to read. It can do this with files or with copied code snippets. It supports JavaScript (JS, JSX), TypeScript (TS, TSX), CSS (including SCSS, Sass, Less), HTML, XML, and JSON code.
🌐
npm
npmjs.com › search
unminify - npm search
Easily unminify nodejs code using esprima and escodegen.
🌐
GitHub
github.com › shapesecurity › unminify
GitHub - shapesecurity/unminify: reverse many of the transformations applied by minifiers and naïve obfuscators · GitHub
let { unminifySource } = require('unminify'); let sourceText = '/* a minified/"obfuscated" JavaScript program */'; console.log(unminify(sourceText)); // or, with options console.log(unminifySource(sourceText, { safety: unminify.safetyLevels.UNSAFE, ...
Author   shapesecurity
🌐
GitHub
github.com › mrcoles › cssunminifier
GitHub - mrcoles/cssunminifier: A tool to unminify CSS—written in node.js
The script is converted from the MrColes.com browser-based css unminifier. Install the script with npm: npm install -g cssunminifier · Run this to print out an unminified version of a CSS file named style.min.css: cssunminifier style.min.css ·
Starred by 125 users
Forked by 25 users
Languages   JavaScript 98.9% | Shell 1.1%
🌐
npm
npmjs.com › package › unminified-webpack-plugin
unminified-webpack-plugin - npm
Start using unminified-webpack-plugin in your project by running `npm i unminified-webpack-plugin`. There are 16 other projects in the npm registry using unminified-webpack-plugin.
      » npm install unminified-webpack-plugin
    
Published   May 07, 2021
Version   3.0.0
Author   Howard.Zuo
🌐
npm
npmjs.com › package › @wakaru › unminify
@wakaru/unminify - npm
🔪📦 Unminify and beautify bundled code. Latest version: 0.2.2, last published: a year ago. Start using @wakaru/unminify in your project by running `npm i @wakaru/unminify`. There are 0 other projects in the npm registry using @wakaru/unminify.
      » npm install @wakaru/unminify
    
Published   Jul 06, 2024
Version   0.2.2
Author   Pionxzh
Find elsewhere
🌐
Reddit
reddit.com › r/learnjavascript › how to un-minify/deobfuscate minified/deobfuscated js code
r/learnjavascript on Reddit: How to Un-minify/Deobfuscate Minified/Deobfuscated JS Code
March 18, 2025 -

I found some large JS files online that I'd really like to peel back and learn from. However, the code is minified/obfuscated (whichever you'd describe it). From what I could get out of searching around it might be done by a bundler of some sort. Below is a snippet of what I'm working with.

P.S. Just to clarify I'm not doing this to learn HOW to write javascript, I've used javascript for most of my projects. I sometimes like to see how some of my favorite apps/websites do what they do.

(() => {
"use strict";
var e,
t,
n,
r = {
8029: function (e, t, n) {
var r = (this && this.__importDefault) || function (e) { return e && e.__esModule ? e : { default: e }; };
Object.defineProperty(t, "__esModule", { value: !0 }), (t.TotalStats = t.WebsiteStats = void 0);
const a = r(n(7294)), l = r(n(932)), o = n(2247), u = n(5761), i = n(2540),
s = l.default.div`
display: flex;
flex-direction: column;
gap: ${(e) => e.theme.spaces.minimal};
margin-bottom: 15px;
`;
(t.WebsiteStats = function (e) { const { t } = (0, o.useTranslation)(), { summary: n } = (0, u.useSummarizedOpenAttempts)(e.website.host), r = e.website.name; return a.default.createElement(
s, null, a.default.createElement(i.Round.Large, null, n.last24HoursAttempts.length), a.default.createElement(i.Paragraph.Small, null, t("interventions.basicBreath.last24Hours", { subject: r })));
}), (t.TotalStats = function () { const { t: e } = (0, o.useTranslation)(), { preventedAttemptsIndication: t, populatedEnough: n } = (0, u.useWebsitesStatsSummary)(),
r = Math.round(60 * t * 3), l = (0, u.useFormatDuration)(); return n ? a.default.createElement( i.Paragraph.Small,
{ style: { textAlign: "center" } }, e("popup.totalTimeSaved", { time: l(r) })
) : null;
});
},
...
}
...
}
)();
🌐
YouTube
youtube.com › jarrod overson
npm Package Highlights - Unminify - YouTube
Friday npm package highlights with Unminify Install command: npm install -g unminify Website: https://unminifier.io/ Github: https://github.com/shapesecurity...
Published   January 18, 2019
Views   134
Top answer
1 of 1
66

It all depends on the environment of your package consumers


NodeJS

For a NodeJS audience your package does not have to be minified, since node runtimes normally have direct file access to the node_modules folder. No network transfers are required, and no additional code transformations are performed prior to running the code.


Bundlers / build pipelines

For consumption through a dev environment that uses a bundler in its build pipeline your package is best not minified. In most cases package consumers do implement their own minification process as part of their builds. Moreover, when providing your package in a module format for example:

  • the dependency tree of implementing codebases can be analyzed more accurately, which might lead to better tree-shaking performance.
  • Common dependencies across packages are actually the same symbols for all such packages (modules are 'singletons'). This helps with code splitting as well as with keeping bundles small.

The above statement relies on the assumption that, if multiple source files are included, minification is preceded by a bundling process. Minifying separate modules is uncommon. If you do provide separate modules, e.g. for a RequireJS runtime in the browser, minification is still relevant, since these files are mostly fetched over the network.


If you decide not to supply minified code, it's still advisable to run your own tests to see if a standard minification process - e.g. with UglifyJS - does not break the software.

Despite that it is for many consumers unnecessary to minify your code, it's still advisable to supply a minified bundle in addition to your regular distribution, just in case somebody could benefit from it.

For plugins / extensions for frameworks like Angular, Vue, Ember etc. it's usually unnecessary to minify your code, since they all implement their own build pipeline, often through a cli.


Script tags / CDN

These are the cases towards which minification is primarily targeted. If you're hosting a file on a CDN, or otherwise provide it over the web for direct <script> tag usage, what you see is what you get. In both cases the file will have to go over the network. Minification saves bytes.


Minification v.s. transpilation

A very important distinction is to be made between these two. Although minification is not always necessary, it is usually your responsibility to transpile any code that is unlikely to be 100% compatible with the target environments of your package audience. This includes:

  • Transpiling new ES20XX syntax to - probably - ES5
  • Polyfilling any ES20XX API implementations

Minification and bundling

If your package consists of a single bundle instead of a bunch of separate modules, minification is always a safe bet. Since a bundler will never try anything funny with a single module/entity (like tree-shaking), it's likely your code will technically not change at all by any build process.


Debugging

If you're going to distribute a minified bundle of your software, it would be nice to also ship a non-minified version for debugging purposes.

🌐
npm
npmjs.com › search
keywords:unminify - npm search
Easily unminify nodejs code using esprima and escodegen.
🌐
GitHub
github.com › the-other-sunny › js-unminify
GitHub - the-other-sunny/js-unminify: Making minified JavaScript readable again 🧐
git clone https://github.com/the-other-sunny/js-unminify.git cd js-unminify npm install
Author   the-other-sunny
🌐
Unminifycode
unminifycode.com
Index of /
Proudly Served by LiteSpeed Web Server at unminifycode.com Port 443
🌐
Stack Overflow
stackoverflow.com › questions › 27980108 › minify-and-unminify-js-based-on-working-enviroment
Minify and Unminify js based on working enviroment
I have large js file approx 800kB (un-minified) and 100KB (Minified).In production environment i minify it online every time and unminify it again in development environment manually.Is there any w...
🌐
Peter Coles
mrcoles.com › blog › css-unminify
Online CSS Unminifier - Peter Coles
Update2: September 2011—the CSS Unminifier now exists as a standalone script that you can run on your computer. I converted it to a node project, which you can install with npm (Node Package Manager) using npm install cssunminifier and you ...
🌐
jsDelivr
jsdelivr.com › package › npm › unminify
unminify CDN by jsDelivr - A CDN for npm and GitHub
May 20, 2022 - js · reverse many of the transformations applied by minifiers and naïve obfuscators · Version 2.0.0 License Apache-2.0 · INSTALL · Version: Static · Static · Latest Patch · Latest Minor · Latest Major · Learn more · Readme Files ...
Published   Jan 07, 2018
🌐
Npm
npm.io › search › keyword:unminify
Unminify | npm.io
jsnicejsniceunminifyminifydeobfuscationobfuscation0.2.0 • Published 9 years ago · babel plugin to rename identifiers in a file to randomly generated pronounceable names · babelbabel-pluginbeautifyidentifiersminifyphoneticrenametransformuglifyunminify2.0.0 • Published 6 years ago · Make minified CSS readable. cssunminifyunminifier0.0.3 • Published 8 years ago · Deobfuscate, unminify and unpack bundled javascript ·