docopt-ng
Jazzband-maintained fork of docopt, the humane command line arguments parser.
What it is and what it does
docopt-ng is a command-line argument parser that derives its parsing rules directly from a help message written in your code's docstring. Instead of defining arguments separately via decorators or configuration objects, you write a usage pattern and option descriptions in plain text, and docopt-ng parses them to validate and extract command-line arguments. It returns a simple dictionary mapping option names, arguments, and commands to their parsed values.
The package is a maintained fork of the original docopt, now under jazzband stewardship with type hints and full test coverage. It supports Python 3.7 and later, has no runtime dependencies, and works with both CPython and PyPy. The approach trades some flexibility for simplicity: if your help message is well-formed, the parser is automatically correct, and your documentation and argument handling stay synchronized.
Use it for:
- Build a simple CLI tool where the help message is the source of truth for argument parsing.
- Add argument parsing to a script without introducing a heavy dependency like argparse or Click.
- Generate a command-line interface for a utility where the usage pattern is already documented.
- Parse subcommands and options in a tool that dispatches to other programs or modules.
- Prototype or maintain a CLI where keeping help text and code in sync is a priority.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses command-line arguments and options from a docstring-based usage pattern, returning a dictionary of parsed arguments without requiring separate argument definitions.
Yes. docopt-ng is a lightweight, actively maintained parser with zero runtime dependencies, permissive licensing, and no known vulnerabilities. Install it if you prefer defining CLI arguments via docstring conventions and want a minimal dependency footprint. Skip it if you need advanced features like type coercion, nested subcommands, or rich help formatting—argparse or Click are better fits for those cases.
Install
docopt-ng on PyPI
pip
pip install docopt-nguv
uv add docopt-ngpoetry
poetry add docopt-ngInstalling docopt-ng
Before you install
Low friction—a pure Python wheel with no runtime dependencies. Actively maintained by jazzband since its fork, with recent commits and complete test coverage.
License in practice
MIT license permits unrestricted use, modification, and distribution in commercial and private projects with minimal attribution requirements.
Quickstart
from docopt import docopt
doc = """Usage: prog.py [--verbose] FILE
Options:
--verbose Enable verbose output.
"""
args = docopt(doc, ['--verbose', 'input.txt'])
print(args)
Requires Python 3.7 or later.
Verify before relying
- Performance characteristics with large or complex usage patterns.
- Compatibility with non-ASCII characters in argument names or help text.
- Behavior when docstring format deviates from documented conventions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 1,172 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,822,308/month — #3,517 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: docopt_ng-0.9.0-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
docoptParses command-line arguments based on a help…
permissive · top 5,000 on PyPI
rich-argparseFormats argparse and optparse help output with…
permissive · top 1,000 on PyPI
autocommandAutocommand converts a Python function into a…
copyleft · top 5,000 on PyPI
arguablyConverts Python functions and their docstrings…
unclear · top 15,000 on PyPI
mandomando wraps argparse to let you build…
permissive · top 5,000 on PyPI
docstring-parserParses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
pydocstringformatterAutomatically formats Python docstrings to…
permissive · top 15,000 on PyPI
argparse-dataclassBuilds command-line interfaces declaratively by…
permissive · top 5,000 on PyPI
entrypoint2Converts Python function signatures and…
permissive · top 15,000 on PyPI
flake8-docstringsIntegrates pydocstyle docstring checking into…
permissive · top 5,000 on PyPI