HomeBlogYAML to JSON: Converting K8s and CI Configs
Data formats· 5 min read·

YAML to JSON: Converting K8s and CI Configs

YAML is easier to write, JSON is easier to consume. Convert YAML to JSON without losing structure, and know which YAML features JSON cannot represent.

YAML to JSON: Converting K8s and CI Configs

Kubernetes manifests, GitHub Actions workflows and most CI systems are written in YAML because humans read it well. Almost every API, SDK and test harness consumes JSON instead. Converting between them sounds trivial until an anchor, a multiline string or an unquoted `yes` changes meaning.

Why convert YAML to JSON at all

  • Feed a config into a tool that only accepts JSON
  • Inspect what a YAML parser actually produced
  • Diff two configs with a JSON-aware tool
  • Store configuration in a document database

The four YAML features JSON cannot express

  • Comments — JSON has none, so every `# note` disappears
  • Anchors and aliases (`&base`, `*base`) — merged at parse time, so the output repeats the data
  • Multiline strings (`|` and `>`) — become single strings with real newlines
  • Duplicate keys — YAML keeps the last one, JSON cannot hold both

None of these are bugs. The conversion is a parse followed by a serialise, so the JSON reflects the effective configuration, not the original file layout.

Watch the type of your values

  • `yes`, `no`, `on`, `off` are booleans in YAML 1.1, strings in YAML 1.2
  • Unquoted `1.0` becomes a number, `1.0.0` stays a string
  • Dates like `2026-11-10` may become date objects
  • `null`, `~` and an empty value all mean null
If a value must stay a string, quote it in the YAML source. Converting first and fixing later is harder because the type is already lost.

How to convert

  1. 1Open the YAML to JSON tool.
  2. 2Paste the YAML — indentation must be spaces, never tabs.
  3. 3Convert and copy the formatted JSON.
  4. 4Validate the result with the JSON Validator before shipping it.

Frequently asked questions

Does the conversion preserve key order?

Most parsers preserve insertion order for mappings, and the output keeps that order. JSON itself does not guarantee ordering, so do not build logic that depends on it.

Can I convert JSON back to YAML?

Yes — use JSON to YAML. Comments and anchors are not restored, because they were never in the JSON.

Why did my indentation break the conversion?

YAML forbids tabs for indentation. Replace them with two spaces and the parse succeeds.

Do it now — free, no signup

Keep reading

Last updated 10 November 2026. Files processed by FilePlume are deleted automatically; nothing is used for training.