YAML ↔ JSON
Convert between YAML and JSON
Paste YAML or JSON and convert it with auto-detection first; additional format details are available in Advanced mode.
The full guide also includes pitfalls, worked examples, snippets, FAQs, and related tools for checking results or troubleshooting.
About this tool
Inspect small examples with a simplified YAML/JSON converter. It selects JSON for input beginning with { or [, otherwise YAML, and regenerates the other representation. Simple block mappings and scalar lists are useful starting points, but this is not a full YAML parser, validator, or lossless round-trip converter. Input drafts are saved locally in this browser.
Production Snippets
Check a small mapping and scalar list
text
Input YAML:
name: cache
retries: 2
tags:
- hot
- warm
Output JSON:
{"name":"cache","retries":2,"tags":["hot","warm"]}Failure Clinic (Common Pitfalls)
A format conversion changes a string into another type
Cause: The simplified JSON-to-YAML formatter can emit a string such as "true" without quotes; the YAML parser can then read it as a boolean. Unsupported syntax can also produce output instead of failing.
Fix: Treat output as a small inspection sample. For real configuration files, use a full YAML implementation and compare decoded values and types with the source.
Frequently Asked Questions
How is the input format selected?
After trimming, input starting with { or [ is parsed as JSON; everything else takes the simplified YAML path. A YAML flow mapping starting with { is therefore treated as JSON, and standalone JSON scalars are not auto-detected as JSON.
Which YAML can I use here?
Use simple block mappings and scalar lists. Anchors, aliases, merge keys, multiple documents, multiline scalars, inline collections, and complex lists of mappings are not reliably supported. Unsupported syntax may produce misleading output rather than an error.
Is conversion lossless?
No. Comments and layout are discarded, and the simplified scalar and string handling can change values or types. For example, a JSON string "true" is emitted without quotes and may become a boolean when parsed as YAML. Keep the source and use a full YAML library for configuration changes.
Is a draft saved?
Conversion is local. The input is saved in this browser’s local storage and restored on return; Clear removes the saved input.
Keep browsing