How to Convert YAML to JSON (and JSON to YAML)
YAML and JSON represent the same data structures โ objects, arrays, strings, numbers, booleans, and null โ in different syntax. Converting between them is a routine task: YAML for human-edited configuration, JSON for APIs and machine processing. The YAML-JSON Converter handles both directions instantly.
- Convert between YAML and JSON formats instantly.
- Covers yaml to json.
- Covers json to yaml.
- Covers edge cases.
- When to Convert.
YAML to JSON
YAML's indentation-based syntax converts to JSON's brace-and-bracket syntax:
YAML:
name: Ultimate Design Tools
tools:
- shadow-generator
- gradient-builder
version: 2.0
JSON:
{"name": "Ultimate Design Tools", "tools": ["shadow-generator", "gradient-builder"], "version": 2.0}
YAML comments (# lines) are lost in conversion because JSON doesn't support comments. Multi-line strings (using | or > block scalars) become single-line strings with \n newline characters.
JSON to YAML
The reverse conversion produces clean, readable YAML from compact JSON. Nested objects become indented blocks. Arrays become dash-prefixed lists. This is especially useful when you need to edit API response data in a more human-friendly format, or when migrating configuration from JSON to YAML.
Edge Cases
YAML types that don't exist in JSON: dates (become strings), anchors/aliases (expanded inline), comments (stripped), binary data (becomes Base64 string). JSON types that behave differently in YAML: bare 'yes'/'no'/'true'/'false' strings in YAML are parsed as booleans โ quote them if you mean the string 'yes'. Numbers like 3.0 in YAML stay as numbers, not strings.
background-size animation or @property registered custom properties instead.When to Convert
Converting API responses (JSON) to YAML for human review. Converting YAML configs to JSON for tools that only accept JSON. Validating YAML structure by round-tripping through JSON. Migrating between configuration formats (Docker Compose YAML to JSON Schema, or vice versa). The YAML-JSON Converter handles files up to 5MB in your browser.
Frequently Asked Questions
How do I convert YAML to JSON?
Are YAML and JSON interchangeable?
Why convert between YAML and JSON?
Use the YAML-JSON Converter โ free, no signup required.
โก Open YAML-JSON Converter