Skip to main content

2026-05-19 · 1 min read

YAML and JSON for config files

Pick the format your runtime reads; convert only when you control both sides.

YAMLJSONconfig

Key takeaways

  • YAML comments and anchors do not survive a blind JSON round-trip.
  • Validate JSON after conversion before committing to main.

Choosing a format

YAML wins for hand-edited configs with comments; JSON wins for strict parsers and generated artifacts.

Convert at repo boundaries (human YAML → machine JSON), not on every local save.

Safe conversion workflow

Paste into YAML ⇄ JSON, inspect the diff, then run JSON Validator on the result.

For API specs, follow with OpenAPI Validator if the JSON is an OpenAPI document.

FAQ

Will conversion change numbers or booleans?

Yes—quotes and types matter. Always diff the output and run your app’s parser in CI.

Kubernetes uses YAML—should I store JSON?

Keep YAML in git for humans; generate JSON only if a downstream tool requires it.