hf auth whoami supports JSON format
Introduced 2026-03-20 · score 0.95
HOW TO USE IT
When a script needs the authenticated Hugging Face identity as JSON, run `hf auth whoami --format json`.
hf auth whoami --format jsonWHY THIS HELPS
Check the authenticated identity in a script that consumes JSON output.
BEFORE THIS CHANGE
The command printed the username and organizations in its default human-readable output.
REQUIREMENTS AND LIMITATIONS
- Version: v1.7.2
- --format json: Selects JSON output; the command’s default format is table.
- Prerequisite: A locally available Hugging Face token is needed to retrieve the authenticated identity; if no token is found, the command reports “Not logged in” and exits.
- Prerequisite: Install the CLI, for example with `pip install -U huggingface_hub`.
- Docs conflict: The v1.7.2 CLI guide says `hf auth whoami` has no options, but the same-version CLI reference and source define `--format`; the source shows the JSON option is implemented.
FIRST-PARTY EVIDENCE
- https://github.com/huggingface/huggingface_hub/releases/tag/v1.7.2
- https://github.com/huggingface/huggingface_hub/blob/v1.7.2/src/huggingface_hub/cli/auth.py
- https://github.com/huggingface/huggingface_hub/blob/v1.7.2/docs/source/en/guides/cli.md
Check the installed version and the source before using it. Entry JSON