FileHint

YAML vs JSON — which one for configuration?

YAML favours human editing with comments and fewer braces; JSON is unambiguous and machine-friendly. Configure with YAML, transport with JSON.

By FileHint editorial teamSupervised by Netwiz LLCEditorial policy

Quick verdict

  • Human-edited configuration → YAML.
  • Program-to-program data and APIs → JSON.
  • Config management (Kubernetes, GitHub Actions) → YAML dominates.

Side-by-side

Property YAML JSON
Comments # lines Not supported (JSONC is the workaround)
Readability High Moderate
Ambiguity Some, especially YAML 1.1 (yes / no) Very low
Anchors / references Yes No
Parser strictness Implementation-dependent Strict

Operational tips

  • Use yaml.safe_loadyaml.load can instantiate arbitrary objects, an RCE-class bug.
  • JSON forbids trailing commas; rely on jq or Prettier to keep formatting consistent.
  • CI config wins for YAML, gRPC and OpenAPI runtime exchanges win for JSON.

See also

References