Paste YAML or open a .yaml/.yml file to validate it and convert it to formatted or minified JSON. Processing stays in your browser.
YAML input
Line 1, column 1
Edit with line numbers and highlighting. Matching brackets are marked at the caret. Press Ctrl/Cmd + Enter to convert.
JSON output
Read-only result
0 characters ยท 0 linesWaiting for YAML
How to convert YAML to JSON
Paste YAML, open a local file, or choose a sample.
Choose single-document or JSON-array output and the desired formatting.
Review live validation or select Convert, then copy or download valid JSON.
Real DevOps uses
Inspect Kubernetes resources as the JSON shape accepted by an API.
Transform Docker Compose, GitHub Actions, or OpenAPI data for scripts.
Validate configuration indentation and expand aliases before debugging.
How YAML types map to JSON
YAML value
JSON value
Conversion note
Mapping
Object
Keys become JSON object property names.
Sequence
Array
Nested sequences remain nested arrays.
String
String
Multiline scalars become strings with escaped line breaks.
Integer or float
Number
Non-finite values become null; large integers can lose JavaScript precision unless quoted.
Boolean
Boolean
true and false remain booleans.
Null or empty document
null
An empty YAML document produces valid JSON null.
What conversion does not preserve
Comments, whitespace, quoting choices, block styles, tags, and anchor names are presentation details that JSON cannot retain. Aliases are expanded. Do not rely on object key order. Duplicate keys are rejected rather than silently overwritten. A truly circular alias is rejected because JSON has no reference type.
Compatibility: this page uses js-yaml 4.1.0 with its default YAML 1.2-compatible schema. One YAML document becomes one JSON root. In JSON array mode, each document in a ----separated stream becomes one array element.
Common YAML errors and fixes
Problem
Likely fix
Tabs in indentation
Replace indentation tabs with consistent spaces.
Inconsistent nesting
Align sibling keys and list markers at the same indentation level.
Missing space after a colon
Write key: value, not key:value.
Malformed sequence
Put a space after each dash and align list items.
Unexpected number or date type
Quote it when it must remain exact text, especially IDs and large integers.
No. Parsing and conversion run in your browser. The YAML text and locally opened files are not sent to Starlight Tools.
Does this converter support YAML 1.2?
It uses js-yaml 4.1.0 and its default YAML 1.2-compatible schema. It does not implement every optional YAML type or preserve presentation details.
Are YAML comments preserved in JSON?
No. JSON has no comment syntax, so comments, quoting style, whitespace, and other YAML formatting are lost during parsing.
How are YAML anchors and aliases handled?
Aliases are expanded into repeated JSON values. A genuinely circular alias is rejected because JSON cannot represent a self-reference.
Can Kubernetes multi-document YAML files be converted?
Yes. Choose JSON array mode to convert every document separated by three hyphens into one JSON array element per YAML document.
Why did a YAML number or date change type?
The parser resolves plain scalars according to its schema. Quote values such as identifiers, dates, or large integers when their exact text and precision must be preserved.
Can JSON be converted back to the original YAML without loss?
No. The data structure can usually be converted back, but comments, anchors, formatting, scalar styles, and sometimes type intent cannot be reconstructed exactly.
How are invalid YAML and duplicate keys handled?
Invalid syntax and duplicate mapping keys stop conversion. The editor keeps the source and reports the parser line, column, excerpt, and a likely fix when available.