hf CLI global output formatting flags apply to every command
Introduced 2026-04-30 · score 0.97
HOW TO USE IT
When a script needs structured or ID-only output from an `hf` command, add `--json` or `-q`/`--quiet`; `--format auto` selects `human` in an interactive terminal and `agent` when invoked by an AI agent. The documented formatting guide says most commands accept these global flags.
hf models ls --search bert --limit 2 --json | jq '.[].id'hf collections ls --owner nvidia -qhf <command> --format autoWHY THIS HELPS
When scripting Hub CLI commands from a coding workflow, request JSON or quiet output without checking whether each command declares those options.
BEFORE THIS CHANGE
Check each command for individually declared `--format`, `--json`, or `-q` / `--quiet` options before using them.
REQUIREMENTS AND LIMITATIONS
- Version: v1.13.0
- --format <value>: Select output format: `auto` (default), `human`, `agent`, `json`, or `quiet`.
- --json: Equivalent to `--format json`; print structured JSON for scripting.
- -q, --quiet: Equivalent to `--format quiet`; print IDs one per line.
- --search <text>: Filter the models listing by search text; used in the documented example.
- --limit <number>: Limit the models listing; used in the documented example.
- --owner <owner>: Select the owner for the collections listing; used in the documented example.
- Prerequisite: Install the `hf` CLI; the guide says it is shipped with `huggingface_hub` and documents `pip install -U "huggingface_hub"`.
- Prerequisite: The guide notes that authentication is needed for some Hub interactions, such as accessing private repositories or uploading; it does not state an authentication prerequisite for the listed read commands.
- Docs conflict: The current guide describes formatting flags as accepted by “most” `hf` commands, while the v1.13.0 release note says every command accepts them. The guide also says jobs commands may consume formatting flags wherever they appear; use `--` when passing those flags through to a script.
FIRST-PARTY EVIDENCE
- https://github.com/huggingface/huggingface_hub/releases/tag/v1.13.0
- https://huggingface.co/docs/huggingface_hub/main/guides/cli#output-formatting
- https://huggingface.co/docs/huggingface_hub/main/guides/cli
Check the installed version and the source before using it. Entry JSON