YAML to JSON Converter
Convert back and forth between YAML syntax and formatted JSON.
Client-Side Execution & Privacy Guarantee
This utility executes 100% locally in your web browser. Your inputs, tokens, queries, and data payloads are never transmitted to any external server or backend.
YAML is widely used for configuration files because of its readability, while JSON is the format most APIs and JavaScript tools expect. Converting between them lets you edit a human-friendly YAML file and then emit the equivalent JSON, or take a JSON payload and produce a YAML representation for documentation. The conversion is performed entirely in the browser.
The tool accepts standard YAML 1.2 constructs including nested mappings, sequences, multiline strings, and simple anchors. On the reverse path it produces clean, indented YAML that preserves key order and uses the most compact representation for each value.
Mapping and sequence translation
YAML mappings become JSON objects and sequences become JSON arrays. Nested structures are preserved at every level. Duplicate keys in a YAML mapping follow the last-key-wins rule that most parsers apply.
JSON objects are emitted as YAML mappings with two-space indentation. Arrays use the block sequence style (dash prefix) unless the array is empty or contains only scalars and a flow style is shorter.
Scalar types and multiline strings
YAML booleans, nulls, integers, and floats are mapped to the corresponding JSON types. Quoted YAML strings remain strings even if their content looks numeric. The reverse conversion quotes a JSON string only when necessary to avoid YAML interpretation.
Literal and folded block scalars (| and >) are converted to ordinary JSON strings with their newlines preserved or folded according to the original indicator. The JSON-to-YAML direction uses a literal block when the string contains newlines.
Anchors, aliases, and limitations
Simple anchors and aliases are resolved during parsing so the JSON output contains the expanded value. Complex merge keys or recursive anchors are rejected with a clear error because they have no direct JSON equivalent.
Custom YAML tags are stripped to their underlying scalar or collection. The converter does not attempt to re-emit non-standard tags, keeping the output portable.
When to use this tool
- Turning a Kubernetes or Docker Compose YAML snippet into JSON for an API call
- Generating a readable YAML version of a JSON configuration for a pull-request description
- Validating that a YAML file parses before it is committed
- Extracting a subset of a large YAML document as JSON
- Teaching the structural equivalence of the two formats
How to use the YAML to JSON Converter
- Paste YAML or JSON into the input editor.
- Select the desired output format.
- Click Convert.
- If a parse error is shown, note the line number, fix the source, and convert again.
- Copy the result or download it with the appropriate extension.
- Use the format button on the output if you want different indentation.
- Clear both panes when the content is sensitive.
Worked examples
Simple YAML mapping to JSON
name: Ada active: true roles: - admin - editor
{
"name": "Ada",
"active": true,
"roles": [
"admin",
"editor"
]
}
Mappings become objects, sequences become arrays, and booleans stay booleans.
JSON object to YAML
{"port":8080,"debug":false}
port: 8080 debug: false
Compact YAML with unquoted scalars where the values are unambiguous.
Common mistakes and tips
- YAML indentation is significant; a single misplaced space produces a parse error at that line.
- Prefer explicit quotes around strings that contain colons or leading special characters.
- The converter preserves key order from the YAML document into the JSON object.
- Very large documents are handled, but anchors that expand to huge structures can increase memory use.
- After conversion you can paste the result into the JSON or YAML formatter for additional cleanup.
Frequently asked questions
Does it support YAML 1.1 boolean variants such as yes/no?
Yes. The common 1.1 boolean and null spellings are recognized and normalized.
Are comments preserved?
No. Comments are discarded during parsing, matching typical YAML-to-JSON behavior.
What is the maximum nesting depth?
Practical documents of a few hundred levels succeed. Extreme recursion may hit browser limits.
Can I convert multiple YAML documents separated by ---?
Only the first document is converted. Split multi-document streams before use.
Does the JSON output use trailing commas?
No. The output is strict JSON.