Skip to main content
SiteIndex
DeveloperReady to use

YAML to JSON

Convert YAML into JSON with validation and instant browser-side output for API and config workflows.

Guide

Interactive workspace

No account required
YAML to JSON

YAML 1.2 mappings and sequences, including nested lists and multiline strings. Comments are omitted from JSON. Duplicate or non-string keys, custom tags, cycles, and values JSON cannot represent produce errors instead of silent data loss. Multi-document files (separated by ---, such as Kubernetes manifests) convert to a JSON array of documents.

You can also drag and drop a .yaml or .yml file onto the input. Conversion runs as you type.

How values are typed (YAML 1.2 core schema)

This converter follows the YAML 1.2 core schema, so words that YAML 1.1 tools turn into booleans stay strings here — the classic “Norway problem”: country: NO converts to {"country": "NO"}, and yes, on and off also stay strings. Hex (0x1A) and octal (0o17) integers do become numbers. Anchors and aliases are expanded into plain values, comments are dropped, and an integer beyond JavaScript's safe range must be quoted in the YAML so it is preserved as text instead of losing precision.

Python (PyYAML)
import json, yaml

data = yaml.safe_load(open('config.yaml'))
print(json.dumps(data, indent=2))
JavaScript (js-yaml)
import { load } from 'js-yaml';

const data = load(yamlText);
console.log(JSON.stringify(data, null, 2));
Command line (yq)
yq -o=json '.' config.yaml

How to use it

  1. Paste a single YAML mapping or sequence.
  2. Select Convert YAML to JSON and review any line-specific error.
  3. Copy the JSON after checking arrays, string types, and values.
What is YAML to JSON?

Convert YAML into JSON with validation and instant browser-side output for API and config workflows.

How it works

A browser-loaded YAML 1.2 parser validates a single mapping or sequence, including nested lists and multiline strings. Comments are omitted from JSON. Duplicate keys, unsupported tags, non-string keys, cyclic aliases, unsafe integers, and non-finite numbers produce explicit errors instead of silent data loss.

Example input and expected output

Input

features:
  - JSON
  - YAML

Expected output

{
  "features": ["JSON", "YAML"]
}
Common uses
  • Inspect YAML configuration as JSON without discarding nested sequences.
  • Convert a multiline YAML setting to its exact JSON string value.
Limitations
  • Only data representable in JSON is accepted; comments and YAML formatting are not retained.
  • Input is limited to 500,000 characters, 100 nested data levels, and bounded alias expansion.
Frequently asked questions
Are YAML lists supported?
Yes. Block and inline sequences, nested mappings, quoted commas, and multiline strings are parsed as structured data.
Why is a duplicate key rejected?
JSON can only retain one value per property. Duplicate YAML keys are rejected so an earlier value is not silently overwritten.
Are comments preserved?
No. JSON has no comment syntax; the conversion preserves supported data values, not YAML comments or original formatting.
Why are some valid YAML values rejected?
JSON cannot represent cyclic aliases, non-string mapping keys, infinity, or NaN. Integers beyond the safe JavaScript range must be quoted to preserve them as strings. Unsupported custom tags and multiple documents are also rejected.
Is configuration data uploaded?
No. Parsing and conversion run in your browser. Input is limited to 500,000 characters, 100 nested data levels, and a bounded number of alias expansions.

Related tools