> ## Documentation Index
> Fetch the complete documentation index at: https://docs.asccli.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Output formats

# Output Formats

> Control how the CLI renders command results with TTY-aware defaults and multiple output formats.

The App Store Connect CLI supports multiple output formats and automatically adapts to your environment.

## Format Options

All commands that return data support three output formats:

* **`json`** - Machine-parseable JSON (default for non-interactive contexts)
* **`table`** - Human-readable table (default for interactive terminals)
* **`markdown`** - Markdown-formatted tables

## TTY-Aware Defaults

The CLI automatically detects whether it's running in an interactive terminal:

```bash theme={null} theme={null}
# Interactive terminal (TTY detected)
asc apps list
# Output: table format

# Piped or CI environment (no TTY)
asc apps list | jq '.data[0].id'
# Output: json format
```

This behavior follows the principle: **human-friendly in terminals, machine-friendly in pipes and scripts**.

## Explicit Format Selection

Override the default with the `--output` flag:

```bash theme={null} theme={null}
# Force JSON in an interactive terminal
asc apps list --output json

# Force table format in a script
asc apps list --output table

# Markdown format (alias: md)
asc apps list --output markdown
```

## Environment Variable

Set a default format across all commands with `ASC_DEFAULT_OUTPUT`:

```bash theme={null} theme={null}
export ASC_DEFAULT_OUTPUT=json
asc apps list  # Uses JSON even in interactive terminals

# Explicit --output flag always overrides ASC_DEFAULT_OUTPUT
asc apps list --output table
```

Valid values: `json`, `table`, `markdown`, `md`

<Note>
  The `--output` flag always takes precedence over `ASC_DEFAULT_OUTPUT` and TTY detection.
</Note>

## Pretty-Printing JSON

For human-readable JSON output, use the `--pretty` flag:

```bash theme={null} theme={null}
asc apps list --output json --pretty
```

Example output:

```json theme={null} theme={null}
{
  "data": [
    {
      "id": "123456789",
      "type": "apps",
      "attributes": {
        "name": "My App",
        "bundleId": "com.example.app"
      }
    }
  ]
}
```

<Warning>
  The `--pretty` flag only works with `--output json`. Using `--pretty` with `table` or `markdown` returns an error.
</Warning>

## Format Examples

### Table Format

```bash theme={null} theme={null}
asc apps list --limit 2 --output table
```

```
ID          NAME        BUNDLE ID           SKU
123456789   My App      com.example.app     APP001
987654321   Other App   com.example.other   APP002
```

### JSON Format

```bash theme={null} theme={null}
asc apps list --limit 1 --output json
```

```json theme={null} theme={null}
{"data":[{"id":"123456789","type":"apps","attributes":{"name":"My App","bundleId":"com.example.app","sku":"APP001"}}]}
```

### Markdown Format

```bash theme={null} theme={null}
asc apps list --limit 2 --output markdown
```

```markdown theme={null} theme={null}
| ID        | NAME      | BUNDLE ID         | SKU    |
|-----------|-----------|-------------------|--------|
| 123456789 | My App    | com.example.app   | APP001 |
| 987654321 | Other App | com.example.other | APP002 |
```

## Implementation Details

Output format resolution follows this priority order:

1. **Explicit `--output` flag** (highest priority)
2. **`ASC_DEFAULT_OUTPUT` environment variable**
3. **TTY detection** (lowest priority)
   * TTY detected → `table`
   * No TTY → `json`

The CLI uses `term.IsTerminal()` to check stdout's file descriptor. This works correctly with:

* Pipes: `asc apps list | jq`
* Redirects: `asc apps list > output.json`
* CI environments: GitHub Actions, GitLab CI, Jenkins
* Docker containers (non-interactive)

## Format Registry

The CLI uses a type-safe output registry system (`internal/asc/output_registry.go`) that maps response types to rendering functions. This ensures:

* Consistent formatting across all commands
* Type-safe row extraction
* Automatic handling of single vs. list responses

Most commands automatically support all three formats without additional code.

## Best Practices

<CardGroup cols={2}>
  <Card title="In Scripts" icon="code">
    Always use `--output json` for reliability and parsing.
  </Card>

  <Card title="In CI/CD" icon="server">
    The CLI defaults to JSON automatically in non-interactive environments.
  </Card>

  <Card title="For Debugging" icon="bug">
    Use `--output json --pretty` to inspect API responses.
  </Card>

  <Card title="For Reports" icon="file-lines">
    Use `--output markdown` to generate documentation snippets.
  </Card>
</CardGroup>

## Related

* [Pagination](/concepts/pagination) - How output formats interact with paginated results
* [Error Handling](/concepts/error-handling) - Error messages always go to stderr
