YAML to JSON — Full YAML 1.2 Guide
YAML (YAML Ain't Markup Language) is designed for human readability. JSON (JavaScript Object Notation) is the lingua franca of web APIs. Converting between them is essential for DevOps, configuration management, and data engineering.
YAML Type System
# Scalars
string: Hello World
quoted: "must be quoted: colons here"
integer: 42
float: 3.14159
bool_true: true # also: yes, on, True, YES
bool_false: false # also: no, off, False, NO
null_val: null # also: ~
# Block scalar (preserves newlines)
multiline: |
Line 1
Line 2
Line 3
# Folded scalar (collapses to one line)
folded: >
This is one
long string
# Sequences (arrays)
fruits:
- apple
- banana
- cherry
# Nested mappings
address:
street: 123 Main St
city: New York
Multi-document YAML
--- # Document 1
name: Service A
port: 8080
--- # Document 2
name: Service B
port: 9090
This converts to a JSON array with two objects when Multi-doc → array is enabled.