Skip to content

YAML to JSON Converter — Convert YAML Config Files to JSON Online

Free

Convert YAML to JSON online instantly. Handles anchors, aliases, and multi-document YAML. Free, browser-based, no upload required.

yaml to json onlineconvert yaml to json freeyaml to json parser
All Developer Tools

Settings guide

Multi-document YAML (`---` separator):

  • ·Split into array — Multiple YAML documents separated by --- are converted to a JSON array of objects.
  • ·First document only — Ignores all but the first YAML document. Use when only the primary document is relevant.

Null handling:

  • ·JSON null — YAML null, ~, and empty values become JSON null.
  • ·Empty string — YAML null/empty values become "". Some APIs prefer this.

Note: YAML comments (# ...) have no JSON equivalent and are discarded during conversion. YAML anchors (&anchor) and aliases (*anchor) are resolved to their full values in the JSON output.

Format comparison

YAML vs JSON as a config format: YAML supports comments, multi-line strings, anchors for reuse, and a cleaner syntax for nested data. JSON is stricter, more portable, and natively parsed by every language without an external library. YAML is better for human-authored configs; JSON is better for machine-to-machine data exchange.

YAML to JSON vs yq / jq: The yq command-line tool converts YAML to JSON: yq eval -o=json file.yaml. jq processes JSON: cat file.yaml | yq eval -o=json | jq '.field'. The online converter is faster for one-off conversions and when you're not in a terminal context.

How it works

1

Parse YAML

The YAML is parsed according to the YAML 1.2 specification. Anchors and aliases are resolved — every reference is replaced with the full value it points to before conversion begins.

2

Map types

YAML types are mapped to JSON equivalents: YAML booleans (yes/no, on/off, true/false) → JSON true/false. YAML null and ~ → JSON null. YAML integers and floats → JSON numbers. Timestamps → JSON strings.

3

Handle multi-document

If the input contains multiple YAML documents separated by ---, each is converted separately according to the selected output mode (array of objects, or first document only).

4

Serialise to JSON

The parsed YAML structure is serialised as formatted JSON with 2-space indentation. Comments are discarded — they have no JSON equivalent.

About this format

YAML is the human-readable config format for Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Ansible playbooks, and countless other DevOps tools. JSON is what REST APIs, JavaScript applications, and most language runtimes consume natively.

Converting between them is a daily task when you need to pass a YAML config's values to an API, seed a database from config data, or debug a Kubernetes object by inspecting it as JSON. Paste YAML and the equivalent JSON is produced immediately — including anchors and aliases resolved, and multi-document YAML split into separate JSON outputs.

Frequently asked questions

What YAML features are supported?+
Anchors and aliases, multi-document YAML (--- separators), all core YAML types (strings, numbers, booleans, null, sequences, mappings), block and flow style, and multi-line strings (literal | and folded > block scalars). YAML tags and custom types are not supported.
Are YAML comments preserved in the JSON output?+
No. JSON has no comment syntax. YAML comments (# ...) are discarded during conversion. If you need to preserve comments, keep the YAML as the source of truth and convert only when needed for API consumption.
How are YAML booleans converted to JSON?+
YAML has several boolean representations: true, false, yes, no, on, off. All are converted to JSON true or false. Note that in strict YAML 1.2, only true and false are booleans — yes/no and on/off are strings. The converter follows YAML 1.1 conventions (accepting all six forms) to match how most tools like Docker Compose behave.
Can I convert a Kubernetes manifest to JSON?+
Yes. Paste the manifest YAML directly. Multi-document Kubernetes manifests (multiple resources in one file, separated by ---) produce a JSON array with one object per resource. You can then use jq or your language's JSON library to extract specific fields.
What happens to YAML anchors and aliases?+
Anchors (&anchor_name) and aliases (*anchor_name) are resolved fully before JSON output. The referenced value is inlined at every alias location. If the anchor defines a mapping, the entire mapping is duplicated at each alias point.

Related tools and guides