Skip to content

JSON Output Reference

Four kinder commands support --output json for scripting and automation: get clusters, get nodes, env, and doctor. JSON output goes to stdout; informational messages (such as progress output from doctor) go to stderr so they do not interfere with piped JSON.

Terminal window
kinder get clusters --output json

Returns a JSON array of strings — one entry per cluster name. An empty result returns [].

["kind","my-cluster"]
Terminal window
# Get the first cluster name
kinder get clusters --output json | jq '.[0]'
# Count how many clusters exist
kinder get clusters --output json | jq 'length'
# Check if a specific cluster exists
kinder get clusters --output json | jq 'any(. == "kind")'
Terminal window
kinder get nodes --output json

Returns a JSON array of objects. Each object has a name field (string) and a role field (string: "control-plane" or "worker"). An empty result returns []. The --all-clusters / -A flag is compatible with --output json.

[{"name":"kind-control-plane","role":"control-plane"},{"name":"kind-worker","role":"worker"}]
Terminal window
# List only control-plane node names
kinder get nodes --output json | jq '[.[] | select(.role == "control-plane") | .name]'
# Count worker nodes
kinder get nodes --output json | jq '[.[] | select(.role == "worker")] | length'
# List nodes across all clusters
kinder get nodes --all-clusters --output json | jq '.[].name'
Terminal window
kinder env --output json

Returns a single JSON object (not an array) with fields: kinderProvider (string), clusterName (string), and kubeconfig (string path).

{"kinderProvider":"docker","clusterName":"kind","kubeconfig":"/Users/user/.kube/config"}

Use --name to target a cluster created with a non-default name:

Terminal window
kinder env --name my-cluster --output json
Terminal window
# Extract the container runtime provider
kinder env --output json | jq -r '.kinderProvider'
# Set KUBECONFIG from JSON output
export KUBECONFIG=$(kinder env --output json | jq -r '.kubeconfig')
Terminal window
kinder doctor --output json

Returns a JSON array of check result objects. Each object has a name field (string) and a status field ("ok", "warn", or "fail"). A message field is included when status is "warn" or "fail" and omitted when status is "ok".

All checks passing:

[{"name":"docker","status":"ok"},{"name":"kubectl","status":"ok"}]

With a failure:

[{"name":"container-runtime","status":"fail","message":"no container runtime found..."},{"name":"kubectl","status":"ok"}]
Terminal window
# Check if any checks failed
kinder doctor --output json | jq 'any(.[]; .status == "fail")'
# Get only failed checks with their messages
kinder doctor --output json | jq '[.[] | select(.status == "fail") | {name, message}]'
# Exit non-zero if any check is not ok (useful in CI)
kinder doctor --output json | jq -e 'all(.[]; .status == "ok")' > /dev/null

These patterns work across multiple kinder commands:

Terminal window
# Pretty-print JSON output
kinder doctor --output json | jq '.'
# Extract all node names as plain text (one per line)
kinder get nodes --output json | jq -r '.[].name'
# CI guard: fail the pipeline if any doctor check is not ok
kinder doctor --output json | jq -e 'all(.[]; .status == "ok")' > /dev/null

The following commands do not support --output json:

  • kinder get kubeconfig
  • kinder create cluster
  • kinder delete cluster

Passing --output json to these commands will return an error.