jsonargparse
Minimal effort CLIs derived from type hints and parse from command line, config files and environment variables.
What it is and what it does
jsonargparse is a library for building command-line interfaces and making Python applications configurable without boilerplate. It reads your function or class signatures—their parameter names, type hints, and docstrings—and automatically generates a CLI that accepts arguments from the command line, YAML/JSON/TOML config files, or environment variables. It handles complex types (unions, optionals, nested dataclasses), dependency injection, and variable interpolation, all while keeping your core code free of CLI-specific decorators or inheritance.
The library is built on argparse but extends it significantly: it parses structured configs into nested hierarchies, supports multiple file formats, and can instantiate objects from parsed configurations. It's used as the foundation for pytorch-lightning's LightningCLI and is actively maintained with semantic versioning and full test coverage.
Use it for:
- Build a CLI tool that accepts both command-line flags and a YAML config file without writing separate parsing logic.
- Make a machine learning training script configurable via config files while keeping the training function clean and testable.
- Create a multi-step application where each step's parameters are defined as function arguments and automatically exposed to the CLI.
- Parse environment variables and config files into a structured dataclass without manual validation or type conversion.
- Support dependency injection in your CLI so users can swap implementations by changing config values.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
jsonargparse creates command-line interfaces and configuration systems from Python type hints and docstrings, parsing arguments from the command line, config files (JSON, YAML, TOML, Jsonnet), and environment variables.
Yes. jsonargparse is a solid choice for any Python project needing a CLI or configuration system. It has low install friction (one required dependency), active maintenance, no known vulnerabilities, and a permissive license. The design is non-intrusive—your code remains clean and testable. Use it if you want to avoid hand-writing argparse boilerplate or if you need config file support beyond what argparse provides.
Install
jsonargparse on PyPI
pip
pip install jsonargparseuv
uv add jsonargparsepoetry
poetry add jsonargparseInstalling jsonargparse
Before you install
Low friction: pure Python wheel with only PyYAML as a required runtime dependency. Active maintenance with a release 23 days ago and consistent commit history. Supports Python 3.10 through 3.14.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install jsonargparse
from jsonargparse import auto_cli
def main(name: str, count: int = 1):
for _ in range(count):
print(f"Hello {name}")
if __name__ == "__main__":
auto_cli(main)
Verify before relying
- Whether the 'substantial user base' claim is quantified beyond pytorch-lightning's LightningCLI adoption.
- Performance characteristics when parsing very large config files or deeply nested structures.
- Compatibility guarantees with optional dependencies (OmegaConf, shtab, argcomplete) across versions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — PyYAML |
| Maintenance | actively maintained — 23 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,354,816/month — #2,650 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: jsonargparse-4.50.0-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
simple-parsingTransforms argparse scripts into structured,…
permissive · top 5,000 on PyPI
tyrotyro generates command-line interfaces and…
permissive · top 5,000 on PyPI
jsonnetJsonnet is a data templating language that…
permissive · top 5,000 on PyPI
argparse-dataclassBuilds command-line interfaces declaratively by…
permissive · top 5,000 on PyPI
ConfigArgParseExtends Python's argparse to parse command-line…
permissive · top 1,000 on PyPI
typer-configAdds configuration-file support to typer CLI…
permissive · top 15,000 on PyPI
targGenerates a command-line interface from…
permissive · top 15,000 on PyPI
configuratorBuilds a configuration store by layering…
permissive · top 15,000 on PyPI
jaraco.loggingAdds command-line argument parsing for Python…
permissive · top 15,000 on PyPI