Output formats¶
nsc ships five output formats: table, json, jsonl, yaml, csv.
Default is table on a TTY and JSON when stdout is piped — the piped
default is JSON even if your config sets a different defaults.output.
Selection precedence (highest first): --output/-o > NSC_OUTPUT env var >
non-TTY → JSON > defaults.output in config (default table).
The five formats¶
| Flag | Purpose |
|---|---|
--output table (default for TTY) |
Rich table with auto-selected columns |
--output json (default when piped) |
Records as a JSON array (single-record writes emit the resulting record dict) |
--output jsonl |
One JSON object per line — good for streaming |
--output yaml |
YAML; useful when you'll round-trip to -f file.yaml |
--output csv |
CSV with nested fields flattened to dotted paths (status.label) |
nsc dcim devices list # table on TTY, JSON if piped
nsc dcim devices list -o json # explicit
nsc dcim devices list --output csv > devices.csv
nsc dcim devices list -o yaml > devices.yaml
nsc dcim devices list -o jsonl | jq '. | select(.status.value == "active")'
Auto-selected columns¶
Heuristic for the table view:
- Always
id. - Then any field named
name,slug, ordisplay. - Then up to 6 scalar fields from the resource's GET response schema.
Override per <tag> <resource> in ~/.nsc/config.yaml:
Unknown column names are silently ignored, so the same config remains valid across NetBox versions and plugin changes.
Nested objects and lists in columns¶
A column may name a nested field directly or drill in with a dotted path:
- A dotted path selects the leaf scalar:
status.value,site.name. - A bare nested object collapses to its human label: FK objects (
site,role,tenant) use theirdisplayfield —rolerendersRouter, not an empty cell — and choice fields (status, …) use theirlabel—statusrendersActive. The precedence isdisplay→label→ compact JSON for objects with neither. The machine value of a choice stays reachable via the dotted path (status.value→active). - A list of objects renders as its members' labels joined with
,(e.g.tags→prod, edge); an empty list renders blank.
This applies to both table and csv. The json, jsonl, and yaml formats
always keep the full nested structure untouched.
Compact JSON¶
One-line records — convenient for jq chains and ndjson tooling.
Pagination and --all¶
nsc dcim devices list # default page (50 records)
nsc dcim devices list --all # follow `next` to completion
nsc dcim devices list --limit 200 # cap at 200
nsc dcim devices list --filter status=active --all
--all shows a Rich progress bar on TTY. For machine output, prefer
--output json --all and pipe.