# argparse — card for AI agents

Command-line argument parser for Node.js, a port of Python's argparse.

Category: Dev workflow and config · npm package `argparse` · latest version 3.0.4 (checked 2026-11-01)
Install: `npm install argparse`
License: PSF-2.0 (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 47.4 (#2277 of all tools, 173 of 299 in its category)
- Used in 2 public projects set up for AI coding agents (0.0%)
- Downloads last week: 384,858,248 (as of 2026-11-24), +39.1% over 4 weeks
- GitHub stars: 515 (as of 2026-11-24)
- Last push: 2026-10-24

## Often used with
dotenv 100.0%, glob 100.0%, cssnano 80.0%, ESLint 100.0%, ansi-escapes 60.0%, Browserslist 60.0%

## Checked alternatives (same job)
- Commander: https://agentgid.com/tools/commander/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/argparse/
- Homepage: https://github.com/nodeca/argparse#readme
- Repository: https://github.com/nodeca/argparse


## argparse for Node.js: Python-style command options

This argparse is a free JavaScript library that reads the options typed after a command in Node.js programs. It copies the argparse module built into Python, so the help screen, error messages and option names work the same way. It is not Python's own module; it is the Node.js version of it.

### Where to use it
- Options for a build script: A script that builds your site takes --pages 120 or --dry-run, checks that numbers really are numbers and prints a help screen with -h.
- One tool with several commands: A small admin tool for your project has separate build and publish commands, each with its own options and help.
- Catch a typo in a command name: Someone types "pubish"; the tool answers "maybe you meant 'publish'?" instead of only an error.
- Bring a Python tool to Node.js: Your team has a Python script with argparse options; the Node.js version keeps the same option names and help text with few changes.
- Handle bad input inside your code: A tool that runs inside a bigger program catches a wrong value as an error object instead of quitting the whole process.

### How to start
- Read the Python argparse documentation for the options; this package has only notes on the differences.
- Pass options as one object instead of Python's keyword arguments.

```
new ArgumentParser({ description: 'example', add_help: true })
```

- Name types as strings such as 'int', 'float' or 'str'.

```
.add_argument('-b', { type: 'int', help: 'help' })
```


### License
Free to use, also in paid products. Keep the Python Software Foundation's copyright notice with the code. If you change the library itself and share it, add a short note of what you changed.

### Good to know
- There is no separate manual; you read Python's argparse pages and the list of differences.
- Version 3 removed the old camelCase method names that many older examples still use.
- Error messages are fixed English text; they cannot be translated.
- The help screen is colored on terminals that support it; set color to false or the NO_COLOR setting for plain text.

Checked 2026-11-11 against: https://github.com/nodeca/argparse/blob/master/README.md, https://github.com/nodeca/argparse/blob/master/CHANGELOG.md, https://github.com/nodeca/argparse/blob/master/LICENSE, https://github.com/nodeca/argparse/blob/master/doc/port_difference.md, https://github.com/nodeca/argparse/blob/master/doc/migrate_v2_to_v3.md, https://docs.python.org/3.14/library/argparse.html, https://registry.npmjs.org/argparse, https://registry.npmjs.org/argparse/3.0.4

### Mistakes to avoid
- Don't: parser.addArgument('--foo') and parser.parseArgs(), copied from argparse 1.x examples → Do: parser.add_argument('--foo') and parser.parse_args() (Version 3 removed the camelCase aliases; in our run on 3.0.4 both methods were undefined.)
- Don't: new ArgumentParser({ addHelp: false }) or { action: 'storeTrue' } → Do: new ArgumentParser({ add_help: false }) and { action: 'store_true' } (Old option and action names were removed; in our run addHelp threw "got an unexpected keyword argument 'addHelp'".)
- Don't: parser.add_argument('--width', { type: Number }) or type: int as in Python → Do: parser.add_argument('--width', { type: 'int' }) (JavaScript has no Python int type, so types are named with strings.)
- Don't: Reading args.dryRun after add_argument('--dry-run') → Do: Read args.dry_run (or set dest explicitly) (Dashes inside option names become underscores; our run printed {"dry_run":true}.)
- Don't: Expecting suggest_on_error on the main parser to also fix typos in a subcommand's choices → Do: Pass suggest_on_error true to each add_parser() call too (In our run the main parser suggested 'publish' for 'pubish', but the publish subcommand did not suggest 'production' for 'prodution' until its own parser had the option.)

### Questions
- Is this Python's argparse? No. It is a JavaScript copy of Python's module for Node.js, following Python 3.14.6.
- Can I use it in a paid product? Yes. The PSF-2.0 license allows any use; keep the copyright notice.
- What changed in version 3? It follows Python 3.14.6, adds colored help, typo suggestions and built-in TypeScript types, and drops the old camelCase names.
- How does it behave on a wrong value? It prints the usage line and an error and exits with code 2, unless exit_on_error is false; our run showed exit code 2.
- Is it still maintained? Yes. Version 3.0.4 came out on 2026-10-24, after five years at 2.0.1.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
