Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

yargs-parser

Turn typed command options into values.

Dev workflow and configNPM

GitHubWebsite

1. License

“Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.”

Any use, with or without a fee, is allowed under ISC.

github.com/yargs/yargs-parser/blob/main/LICENSE.txt

From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error

What yargs-parser does

yargs-parser is a small free JavaScript library that reads options typed after a command, like "--width 1200 --dry-run", and gives your code ready values. Numbers become numbers, on-off switches become true or false, and other words are kept in a list. It is the part of the yargs toolkit that only reads options; it does not print help or check for mistakes.

What people build with it

Options for your own script

You have a small Node.js script that resizes photos or cleans a folder. It reads "-w 1200 --dry-run" without you splitting the text by hand.

Commands typed in a chat box

A team chat bot or a web console gets "/deploy --env staging --force" as one line of text and needs the parts as values.

A command box in a web page

A tutorial site or an in-browser playground lets visitors type options, and the page reads them without a server.

Quiet, normal or chatty output

Your tool prints more detail with -v and even more with -vvv; the library counts the letters for you.

Pass extra words to another program

A wrapper script keeps everything after "--" untouched and hands it to the program it starts, like a test runner.

yargs-parser popularity

48 / 100
Gid Score, #2165 overall
394M
downloads a week, npm
520
GitHub stars
3
agent projects use it
yargs-parser: downloads per weeknpm, yargs-parser 394,038,993
yargs-parser: GitHub starsyargs/yargs-parser 520

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How yargs-parser is used

  • yargs-parser joined the catalog on its public numbers (394,038,993 downloads a week on npm and 520 GitHub stars), not on our project count: it is a dependency in 6 public GitHub projects of our scan, 3 of them set up for AI coding agents.
  • The most used alternative in our scan is Commander (174 projects).
  • Projects that use it most often also use tsx (66.7%), Prettier (66.7%), Vitest (66.7%).

Often used with

In 66.7% of its projects
In 66.7% of its projects
In 66.7% of its projects
In 50.0% of its projects
In 50.0% of its projects
In 50.0% of its projects
In 83.3% of its projects
In 66.7% of its projects

More about yargs-parser

Funding
  • GitHub Sponsors: https://github.com/shadowspawn
  • thanks.dev: https://thanks.dev/u/gh/shadowspawn
  • Tidelift: https://tidelift.com/funding/github/npm/yargs-parser
  • 4 GitHub sponsors

See all

More in Dev workflow and config

Alternatives

yargs-parser This page

ISCGid 48394M/wk

yargs

Pick yargs when your tool needs automatic help and usage text, commands and checks, not only the raw values.

Commander

Pick Commander for a complete command-line app with sub-commands and help with little setup.

MITGid 82788M/wk

minimist

Pick minimist when you want an even smaller option reader with fewer settings.

Compare yargs-parser with another tool

Get started

Tell your AI assistant

“Use yargs-parser (pin yargs-parser@22.0.0, Node.js 20.19+ or 22.12+) to read the options of our script; declare number, boolean, array and string options and defaults, and turn greedy-arrays off if a list option comes before file names.”

  1. Add the package to your project.

    npm i yargs-parser --save

    From github.com/yargs/yargs-parser/blob/main/README.md

  2. Pass it the words after your command, or one string, and read the result.

    const argv = require('yargs-parser')(process.argv.slice(2))
    console.log(argv)
    

    From github.com/yargs/yargs-parser/blob/main/README.md

  3. Tell it which options are numbers, switches, lists or text, and give defaults.

    import parser from 'yargs-parser'
    
    const argv = parser('--foo=99 --bar=9987930', {
      string: ['bar']
    })
    

    From github.com/yargs/yargs-parser/blob/main/README.md

Mistakes to avoid

require('yargs-parser') with yargs-parser 22 on Node.js 18 or 20.0-20.18
Upgrade to Node.js 20.19+ or 22.12+, or pin yargs-parser@21.1.1 on older Node.js

Version 22 is published as an ES module only and lists those Node.js versions as its minimum.

array: ['format'] and then shrink --format webp avif photo.jpg
Put files first, or set configuration: { 'greedy-arrays': false } so a list takes one word per flag

A list option keeps taking the following words; in our run photo.jpg ended up inside format.

Counting on it to reject unknown or misspelled options
Check argv against your own list of allowed keys, or use yargs' strict mode for real validation

Unknown options are accepted as new keys; in our run --output-dir became outputDir with no error.

parse(['-f', 11, '--zoom', 55]) with numbers in the list
parse(['-f', 11, '--zoom', 55].map(String)), or join the list into one string

The README asks for strings; convert mixed values before you pass them.

Reading parser(...) result only and missing that an option needed more words
Use parser.detailed(args, opts) and check its error field

The plain call returns values only; detailed() also returns the error, as in our run with narg.

Questions

Does it print a --help screen?

No. It only turns the typed words into values; yargs, which is built on it, adds help and usage text.

Can I give it one string instead of a list of words?

Yes. It takes a string or a list of strings.

Does --no-color work?

Yes. By default an option that starts with --no- is read as that option set to false.

Does it work in the browser?

Yes, through its browser entry, since version 19. Loading settings from files is not supported there.

Can I use it in a paid product?

Yes. The ISC license allows any use with or without a fee; keep the notice in copies.