Skip to content

Typer

A Python library for building command-line apps from ordinary type-annotated functions.

Stars
20.2k
Forks
995
Licence
MIT
Language
Python
Last update
5 days ago
Type
Library

What it is

Typer is a Python library for building command-line interface (CLI) programs. You write normal Python functions with type hints, and Typer turns their parameters into command-line arguments and options, including automatic help text and shell completion. It also includes a typer command that can run an existing Python script as a CLI without changing the script.

  • Turn a Python function into a command that takes a name argument and prints a greeting
  • Build a tool with subcommands such as hello and goodbye, each with its own options
  • Run an existing script as a CLI with the typer command, even if it does not use Typer internally
  • Get automatic --help output and shell auto-completion for your command-line program

Great for

  • Python developers writing small or medium command-line tools
  • People who already use type hints and want less boilerplate argument parsing
  • Making a quick CLI out of an existing script using the typer command
  • Teams building multi-command tools with subcommands and groups

Not ideal for

  • Non-Python projects, since Typer is a Python library (reason: it only runs in Python)
  • Anyone who needs a graphical interface rather than a terminal program (reason: Typer builds CLIs only)
  • Beginners who have not yet learned basic Python functions and type hints (reason: the examples assume that knowledge)
Step-by-step guide: how to use TyperInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Python 3.10 or newer, as typical for the uv workflow (not stated explicitly in the README; verify) · uv (recommended) or pip inside a virtual environment

    Add Typer to a uv project

    uv add typer
  2. 2

    Run it

    • Create a file main.py containing a function with a typed parameter, such as name: str.
    • Add import typer and call typer.run(main) under if __name__ == "__main__".
    • Run it with uv run python main.py Camila to see the greeting.
    • Run uv run python main.py --help to see the automatically generated help.
  3. 3

    Get the most out of it

    • Use app = typer.Typer() with @app.command() to build subcommands once the single-function form is not enough.
    • Install shell completion with --install-completion, which the README says works when you create a Python package.
    • Use the typer command (for example, typer main.py run) to run existing scripts as CLIs without modifying them.
    • Use bool parameters to get automatic --formal and --no-formal options.

Downloads

Strengths

  • Uses Python type hints to define arguments, so there is less code to write and maintain
  • Generates help text and shell completion automatically, as shown in the README examples
  • Builds on the same style as FastAPI, which may feel familiar to people who use that framework

Trade-offs

  • Only useful for Python projects, so it does not help with other languages
  • The README is truncated here, so details on advanced features and edge cases could not be verified
  • Shell completion works fully only in certain setups, such as inside a package or via the typer command, per the README note

How it compares

ProjectStarsTypeLevelUpdatedBest for
typer (this)20.2kLibrarybeginner5 days agoPython developers writing small or medium command-line tools
rich57.7kLibrarybeginner5 months agoPython developers who write command-line scripts and want clearer output
spaceship-prompt20.6kDev toolbeginner10 days agoZsh users who want useful information in their prompt without much setup
upterm19kAppintermediate7.5 years agoDevelopers who want to try an Electron-based terminal with autocompletion
prezto14.6kFrameworkbeginner7 months agoPeople who use Zsh and want a ready-made starting configuration
pure14.5kDev toolbeginner30 days agoDevelopers who use zsh and want a simple, readable prompt

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.