Last modified: Aug 11, 2025 By Alexander Williams

Python Typer Help Text Guide

Typer makes building CLI apps easy. One key feature is automatic help text generation. This guide shows how to customize it.

Basic Help Text in Typer

Typer automatically creates help text for your CLI app. It uses function docstrings and parameter info.


import typer

app = typer.Typer()

@app.command()
def greet(name: str):
    """Say hello to someone"""
    typer.echo(f"Hello {name}")

if __name__ == "__main__":
    app()


$ python app.py --help
Usage: app.py [OPTIONS] NAME

  Say hello to someone

Options:
  --help  Show this message and exit.

Customizing Command Help

Use the help parameter in @app.command() to override docstring help text.


@app.command(help="Greet a person by name")
def greet(name: str):
    typer.echo(f"Hello {name}")

Parameter Help Text

Add help for individual parameters using typer.Option or typer.Argument.


@app.command()
def greet(
    name: str = typer.Argument(..., help="The person to greet"),
    loud: bool = typer.Option(False, help="Shout the greeting")
):
    greeting = f"Hello {name}"
    if loud:
        greeting = greeting.upper()
    typer.echo(greeting)

For more on arguments vs options, see our Python Typer: Arguments vs Options guide.

Epilog and Short Help

Add extra text after help with epilog. Use short_help for brief descriptions.


@app.command(
    short_help="Greets someone",
    epilog="Example: python app.py greet John"
)
def greet(name: str):
    typer.echo(f"Hello {name}")

Customizing the Help Command

Typer lets you modify the help command itself. Change its name or behavior.


app = typer.Typer(
    help="My Awesome CLI",
    add_completion=False,
    no_args_is_help=True
)

For complex apps, consider using subcommands to organize functionality.

Styling Help Text

Typer supports rich text formatting for better help text appearance.


@app.command(help="[bold green]Greet[/] someone by [blue]name[/]")
def greet(name: str):
    typer.echo(f"Hello {name}")

Best Practices

Keep help text concise but informative. Document all options and arguments clearly.

Use consistent formatting. Group related commands when using multiple commands.

Test your help text by running your app with --help frequently.

Conclusion

Typer's help system is powerful yet simple. Well-crafted help text improves user experience.

Combine docstrings, parameters, and Typer features to create professional CLI apps. Remember to test all help output.

For more Typer tips, check our Type Hints Usage Guide.