DevKits

YAML to JSON Converter

Convert YAML documents to JSON online. Supports YAML 1.2, multi-document streams, and produces pretty-printed JSON output.

Last updated:

120 chars

Paste YAML above to convert it to pretty-printed JSON instantly. Supports multi-document streams and resolves anchors/aliases. Everything runs in your browser.

What is YAML → JSON?

Converting YAML to JSON is essential when a tool or API needs JSON but your source of truth is YAML — feeding a Kubernetes manifest into a JSON-only linter, or importing a CI config into code. The converter parses YAML 1.2 (including anchors, aliases, and multi-document streams) and emits standard, pretty-printed JSON.

How to convert YAML to JSON

  1. 1Paste your YAML document into the input pane.
  2. 2The tool parses it and renders equivalent JSON on the right.
  3. 3If the YAML contains multiple documents separated by ---, the output is a JSON array.
  4. 4Copy the JSON for use in an API call, config loader, or test fixture.

Use Cases

Feed YAML into JSON-only tools

Many linters, validators, and APIs accept only JSON. Convert your YAML config first.

Inspect resolved anchors

See what a YAML file with &anchors and *aliases actually expands to, since JSON has no references.

Import config into code

Turn a docker-compose.yml or values.yaml into JSON to embed as a JavaScript object or fixture.

Code Examples

Input YAML

name: web
ports:
  - 80
  - 443

Output JSON

{
  "name": "web",
  "ports": [80, 443]
}

Key Concepts

Multi-document streams
A single YAML file can hold multiple documents separated by `---`. Converting to JSON yields an array, one element per document.
Anchor resolution
`&anchor` defines a reusable block and `*alias` references it. During conversion these are expanded inline, since JSON can't represent references.
Type coercion
YAML auto-detects types: `true`, `42`, and `3.14` become boolean/number. Quote them in YAML if you need strings.

Tips & Best Practices

  • Watch for the YAML 'Norway problem': `no`, `off`, `yes` may parse as booleans unless quoted.
  • Multi-document YAML becomes a JSON array — expect `[ ... ]` at the top level if you used `---`.
  • If parsing fails, check indentation first: YAML is whitespace-sensitive and rejects tabs.
  • Round-tripping YAML → JSON → YAML can drop comments and reorder keys; keep YAML as the source of truth.

Frequently Asked Questions

Does it support multi-document YAML?

Yes. If the input contains multiple documents separated by ---, the output is a JSON array where each element corresponds to one document.

How are YAML anchors and aliases handled?

Anchors (&name) and aliases (*name) are resolved during parsing, and the resulting JSON contains the expanded values.

Related Tools