Skip to content

Add --json-default (or bare --json) to mirror default table columns in list commands #13765

Description

@chirag127

Describe the feature or problem you'd like to solve

gh issue list (and gh pr list, gh run list, etc.) print a nice default table: number, title, labels, state, updated-at. But the moment you want JSON — the 90% case for scripting — --json requires you to enumerate every field:

$ gh issue list --repo cli/cli --json
Specify one or more comma-separated fields for `--json`:
  assignees author blockedBy blocking body closed closedAt ...

That's ~25 fields to pick from every time. Every script or agent ends up hardcoding something like --json number,title,state,labels,updatedAt — which is fragile (typos), verbose, and inconsistent across scripts.

Proposed solution

Add a --json-default shortcut (or accept --json with no argument, or --json=default) that emits the same columns the default table shows:

$ gh issue list --repo cli/cli --json-default
[{"number": 13764, "title": "...", "state": "OPEN", "labels": [...], "updatedAt": "..."}]

Value:

  • Matches the mental model of "give me the table, but as JSON."
  • Stable for scripts that don't care about specific fields, just want to iterate over the list they'd otherwise see on-screen.
  • Discoverable — --help can document the default set per command.

Alternative shape: --json without arguments prints the default columns instead of erroring (arguably a small backwards-compat break, but the current error path is a UX cliff).

Additional context

Distinct from #10385 (which is scoped to gh search prs implying --json when --jq is used). This is about the default column set being reachable in JSON mode across all ... list commands.

Related: #8890 (hyperlinks/headers in gh pr list), #9152 (piped-output edge cases).

Not asking for auto-detection or magic — just a named shortcut for the columns the tool already knows are the sensible defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-issuerelating to the gh issue commandgh-prrelating to the gh pr commandgh-runrelating to the gh run command

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions