YAML to JSON

Converter

Convert YAML data to formatted JSON with full nested structure support. Drop in config files for clean, indented JSON you can paste anywhere. Anchors expand.

Converted
YAML
6 lines
JSON
8 lines

About YAML to JSON

YAML is the dominant config format in DevOps and cloud-native tooling, but programs, APIs, and most programming languages prefer JSON. This tool parses YAML and converts it to standard JSON locally in your browser — expanding anchors (&) and references (*), splitting multi-document (---) input into a JSON array, and handling block scalars (| and >) while respecting indentation. Values like true/false, null, numbers, and dates are typed automatically, with a caveat worth remembering: YAML 1.1 also reads bare on/no/yes as booleans and date-like strings as timestamps, so quote those in the source if they must stay strings. On parse failure, the reported line number helps you fix it fast, effectively making the tool a lightweight YAML lint check. For example, YAML name: Tom and age: 20 converts to {"name":"Tom","age":20}, with indentation restored as nesting — ready for jq, JSONPath, or any JSON pipeline.

How to Use

  1. Open the YAML to JSON tool
  2. Select the source and target formats
  3. Adjust the output options as needed
  4. Click the Convert button; results appear in real time
  5. Copy or export the result

Use Cases

  • Store configs — Convert YAML to JSON before writing to a database or posting via API, avoiding an extra YAML parser on the backend.
  • Debug K8s manifests — Convert kubectl-exported YAML to JSON, then extract fields with jq or JSONPath.
  • Consume configs in frontend — Browsers natively support JSON.parse, so convert YAML to JSON for direct frontend use.
  • Expand anchors — Expand anchor-reused YAML into full JSON to see the actual effective values.
  • Validate format — A failed conversion means invalid YAML syntax — use it as a quick lint check.
  • Preprocess Ansible vars — Convert Ansible inventory YAML to JSON so external scripts can consume host variables without a YAML library.
  • Seed test fixtures — Write test data in concise YAML syntax, then convert to JSON for use in unit-test fixtures.

FAQ

Does it support multi-document YAML?

Yes. YAML documents separated by --- become a JSON array, with each document as one element.

What happens to YAML anchors and references?

They are fully expanded. &anchor definitions and *ref references are inlined into actual repeated content, since JSON has no reference mechanism.

Are dates and booleans auto-detected?

Yes. YAML true/false, null, numbers, and dates are typed accordingly; quote them in YAML to keep them as strings.

Why does it report an indentation error?

YAML is very indentation-sensitive: siblings must align and tabs are forbidden. The error gives a line number to check.

How are multi-line block scalars converted?

| and > blocks become a single string with real newlines; the folded (>) newlines are normalized to spaces in the JSON string.

Can I convert back to YAML?

Yes, use our JSON to YAML tool for the reverse direction.

Advertisement