Click vs Typer: Same CLI, Two Frameworks
Same CLI built with Click and Typer — see which one wins forever.
OUR PICK: TYPER
Type hints • Auto docs • 70% less code • Built by FastAPI creator
Click (Old King)
import click
@click.command()
@click.option('--name', required=True, help='Your name')
@click.option('--age', type=int, help='Your age')
@click.option('--shout', is_flag=True, help='Shout the message')
def hello(name: str, age: int | None, shout: bool):
"""Simple greeting CLI"""
msg = f"Hello {name}!"
if age:
msg += f" You are {age} years old."
if shout:
msg = msg.upper() + "!!!"
click.echo(msg)
if __name__ == '__main__':
hello()
Typer (New Emperor)
#!/usr/bin/env python
import typer
app = typer.Typer(help="Simple greeting CLI")
@app.command()
def hello(
name: str = typer.Option(..., "--name", help="Your name"),
age: int | None = typer.Option(None, "--age", help="Your age"),
shout: bool = typer.Option(False, "--shout", help="Shout the message")
):
"""Simple greeting CLI"""
msg = f"Hello {name}!"
if age:
msg += f" You are {age} years old."
if shout:
msg = msg.upper() + "!!!"
typer.echo(msg)
if __name__ == "__main__":
app()
Final Verdict
| Feature | Click | Typer | Winner |
|---|---|---|---|
| Type Hints | No (manual) | Native | Typer |
| Code Length | ~30 lines | ~18 lines | Typer |
| Auto Documentation | Basic | Perfect (like FastAPI) | Typer |
| Async Support | Hard | Native | Typer |
| Created By | Pallets (Flask team) | Sebastián Ramírez (FastAPI) | Typer |
| Future-Proof | Mature but aging | Modern Python | Typer |
Our pick for new projects: Typer
Use Typer for all new projects. Click only for legacy.
How to read this Click vs Typer comparison
This page shows the same small greeting command written twice: once with Click's decorators and once with Typer's type-hinted function parameters. Each version has a copy button, so you can run both and compare the help output.
Example
Input: Save the Typer version as hello.py and run python hello.py --name Ada --age 36 --shout.
Output (excerpt):
HELLO ADA! YOU ARE 36 YEARS OLD.!!!
Limits
- Typer is built on top of Click, so the two are not competitors in the usual sense. Typer gets its options from type hints. Click asks you to declare each option in a decorator.
- Click is a good fit when you want explicit control, plugin-style command groups, or an older codebase that already uses it. Typer is a good fit for new code that already uses type hints.
- Both need a
pip install(clickortyper). Neither is in the standard library. For very small scripts,argparsemay be all you need. - The table is a summary of opinions, not a benchmark. Check each project's current documentation for features such as async support before deciding.
Privacy
All conversion happens in JavaScript inside your browser. The tool code on this page makes no network request with what you type, so your input is not uploaded or stored by PyInns. (The page itself still loads ads and shared libraries from third-party CDNs.)