mrkeyoor.com_
Sun 20 Sept 07:02 UTC
npmCLI & Toolingupdated 20 Sept 2026

minimist review

minimist 1.2.8 is one function that maps an argv array to an object. Non-options land in _, long and short flags become properties, --no-x becomes x: false, and numeric-looking tokens become numbers unless declared as strings. Options cover aliases, defaults, booleans, strings, early stopping, a separate -- tail, and an unknown-token callback. It does not provide help, subcommands, required arguments, choices, or structured usage errors. Our install measured a 3.8 KB minified and 1.6 KB gzipped browser bundle, though command-line parsing normally stays in Node.

114.4Mdownloads / wk
Verdict

minimist 1.2.8 installed in 0.3 seconds as one 1 MB package with 0 audit findings in our sandbox, but it supplies no types or usage errors. Keep it for tiny or compatibility-sensitive parsers; current Node scripts should try node:util parseArgs, and public CLIs should use a command framework.

We installed it

Lab card: what happened when we installed minimistScreenshot of minimist documentation
Install✓ · 0.3s1 package on disk · 1 MB
ImportESM import works · require() works · CommonJS package
Browser1.6 KBgzipped (3.8 KB minified), bundled with esbuild
Typesno TypeScript types found
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)

Answers from our run

Does minimist install cleanly?

Yes. In a fresh container with an empty cache, npm install minimist finished in 0.3s, leaving 1 package and 1 MB on disk. npm audit reported no known vulnerabilities.

How much does minimist add to a browser bundle?

1.6 KB gzipped (3.8 KB minified) when the whole package is bundled for the browser with esbuild. Importing only part of it is usually smaller.

Does minimist work with both ESM and CommonJS?

Yes. Both import 'minimist' and require('minimist') worked in Node 22 in our run. The package is published as CommonJS.

Does minimist include TypeScript types?

No type declarations were found in our install, so TypeScript users need their own declarations.

minimist or mri: which should you use?

mri: Choose it for another compact parser with aliases and declared string or boolean flags. minimist 1.2.8 installed in 0.3 seconds as one 1 MB package with 0 audit findings in our sandbox, but it supplies no types or usage errors.

When should you not use minimist?

Supported Node versions include node:util parseArgs, which declares option types and can reject unknown flags without an npm package.

API stability5/5Version 1.2.8 still exposes one parsing function and the same compact options object for strings, booleans, aliases, defaults, stopEarly, '--', and unknown handling. The README's CommonJS and ESM examples match what loaded in our Node 22 sandbox. This stability comes with a fixed scope: the package has not grown validation, subcommands, typed declarations, or help generation that could disturb existing behavior.
Docs3/5The README explains the full 1.2.8 option surface and shows number conversion, --no- negation, boolean consumption, the double-dash split, positionals, and unknown callbacks. It is short enough to scan in one sitting. It gives little direction on strict policies, grouped-short ambiguities, TypeScript, the package's advisory history, or Node's built-in parseArgs, leaving important production decisions to callers.
Maintenance3/5GitHub shows an unarchived repository pushed on December 30, 2025, with 14 open issues and pull requests. npm still marks 1.2.8, released in February 2023, as latest and does not deprecate it. A tiny parser can be finished rather than abandoned, but teams should not expect new Node conventions, bundled declarations, or richer diagnostics to arrive quickly through package releases.
Ecosystem4/5npm recorded 155,277,587 downloads from August 19 through 25, 2026, and GitHub reported 662 stars. Much of that reach comes through established build tools and transitive dependency graphs. The zero-dependency CommonJS package loaded through both module systems in our check. Native parseArgs weakens its case in new Node programs, and featureful public commands commonly need Commander or Yargs instead.

Use it if

  • A small Node script needs loose parsing for a few flags and must still run where node:util parseArgs is unavailable.
  • A wrapper deliberately forwards unknown arguments after -- to another executable.
  • An older tool already depends on minimist behavior for grouped short flags, number coercion, and aliases.
  • stopEarly is enough to separate one command word from a second tiny parsing pass.
Skip it if

Setup reality

We installed minimist 1.2.8 in a clean Node 22 Bookworm sandbox. npm finished in 0.3 seconds and left one package using 1 MB. The package was 136 KB unpacked and declared 0 direct dependencies and 0 peers. npm audit reported 0 known vulnerabilities. It is CommonJS with no exports map; require() and ESM default import both worked in our checks. We found no TypeScript declarations.

Pass process.argv.slice(2), or Node's executable and script path appear in _. Minimist coerces numeric-looking tokens unless their names are listed under string; putting _ there also preserves positional text. That matters for 001, version 1.10, and identifiers beyond safe integer range. Declare booleans too, because a boolean option can consume a following literal true or false.

Unknown options are accepted unless unknown(raw) returns false. The callback receives raw tokens and does not print an error, so the application must track the rejected value, account for aliases and = syntax, and set an exit code. With {'--': true}, tokens after -- move to argv['--']; without it they join _. stopEarly moves everything after the first positional into _, which is only manageable for shallow command shapes.

Minimist does not validate ranges, require fields, load environment variables, create help, or protect a spawned command from unsafe arguments. Validate every parsed field before using it as a path, port, or executable input. Older releases had prototype-pollution advisories, while npm audit found 0 issues in our 1.2.8 install. A full import bundled to 3.8 KB minified and 1.6 KB gzipped, but browser UI should normally parse URL or form state instead of command arguments.

Patterns

Read flags and positionals parse-node-arguments

const minimist = require('minimist');

const args = minimist(process.argv.slice(2));
console.log(args._, args.verbose);

slice(2) removes the Node executable and script path. Any undeclared flag is accepted by default.

Call minimist from ESM import-from-esm

import minimist from 'minimist';

const args = minimist(process.argv.slice(2), { boolean: ['verbose'] });

The CommonJS package loaded through an ESM default import in our Node 22 check, despite having no exports map.

Disable numeric coercion keep-identifiers-as-strings

const args = minimist(process.argv.slice(2), {
  string: ['version', 'account', '_'],
});

Adding _ preserves positional strings. List every identifier-like option so 001 and 1.10 do not become numbers.

Define aliases and defaults configure-aliases

const args = minimist(process.argv.slice(2), {
  alias: { p: 'port', v: 'verbose' },
  string: ['port'],
  boolean: ['verbose'],
  default: { port: '3000', verbose: false },
});

Both alias names appear on the result. Pick one canonical property for application code.

Turn a boolean default off negate-default-flag

const args = minimist(process.argv.slice(2), {
  boolean: ['color'],
  default: { color: true },
});

// --no-color sets args.color to false

Declaring color as boolean keeps the next non-boolean token from being consumed as its value.

Preserve child-command arguments forward-double-dash-tail

const args = minimist(process.argv.slice(2), { '--': true });
spawn('worker', args['--'], { stdio: 'inherit' });

Validate the executable independently. The preserved tail may contain options intended for the child.

Stop at the first positional split-one-subcommand

const outer = minimist(process.argv.slice(2), { stopEarly: true });
const [command, ...rest] = outer._;
const inner = command === 'build' ? minimist(rest, { boolean: ['watch'] }) : null;

One shallow split is workable. Nested commands need a library that owns command routing and help.

Apply an option allowlist reject-unknown-flags

const allowed = new Set(['--port', '-p', '--verbose', '-v']);
let rejected;
const args = minimist(process.argv.slice(2), {
  string: ['port'], boolean: ['verbose'], alias: { p: 'port', v: 'verbose' },
  unknown(raw) {
    if (raw.startsWith('-') && !allowed.has(raw.split('=')[0])) { rejected = raw; return false; }
    return true;
  },
});
if (rejected) throw new Error(`unknown option: ${rejected}`);

Minimist does not format the usage error. Test aliases, equals syntax, and grouped short flags against this policy.

Understand compact short flags parse-short-groups

const args = minimist(['-abc', '-n5']);
console.log(args.a, args.b, args.c);
console.log(args.n);

-abc becomes three booleans and -n5 becomes n: 5, which can turn a mistyped word into several accepted options.

Consume an explicit boolean parse-boolean-literal

const args = minimist(['--watch', 'false', 'src'], { boolean: ['watch'] });
console.log(args.watch); // false
console.log(args._);     // ['src']

A declared boolean consumes the following string when it is exactly true or false.

Check required values after parsing validate-required-option

const args = minimist(process.argv.slice(2), { string: ['output'] });
if (!args.output) {
  console.error('usage: convert --output <path>');
  process.exitCode = 2;
}

Required options and exit behavior belong to application code because minimist only parses tokens.

Use the built-in Node parser replace-with-node-parser

import { parseArgs } from 'node:util';

const { values, positionals } = parseArgs({
  options: {
    port: { type: 'string', short: 'p', default: '3000' },
    verbose: { type: 'boolean', short: 'v' },
  },
  allowPositionals: true,
  strict: true,
});

node:util parseArgs can reject undeclared flags and keeps values typed according to the option definition.

Alternatives

PackageRegistryPick it when
mrinpmChoose it for another compact parser with aliases and declared string or boolean flags.
yargs-parsernpmChoose it for detailed parsing rules without adopting Yargs command and help layers.
commandernpmChoose it for user-facing commands that need subcommands, validation, and generated help.

More cli & tooling guides

commander · chalk · typescript · esbuild · yargs · click · the whole shelf →

How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.