JSON ↔ YAML (controlled subset)
Bidirectional conversion over a controlled YAML subset: mappings, sequences, scalars, quoted strings, booleans and null. Alias bombs, tags, block scalars and excessive depth are rejected.
Inputs and parameters
input— Input (JSON or YAML)direction— Directionindent— Indent spaces
Real example
{"name":"Ada","active":true,"deleted":null,"empty":{},"tags":["a",2],"created":"2024-05-01","__proto__":{"polluted":false}}
→ name: Ada
active: true
deleted: null
empty: {}
tags:
- a
- 2
created: "2024-05-01"
__proto__:
polluted: false
Limits and failure handling
Only a single-document controlled YAML subset is accepted; full YAML 1.2 compatibility is not claimed. Flow []/{} collections must fit on one line. No anchors, tags, block scalars or complex keys. Dates remain strings; aliases and binary tags are explicitly rejected. Input is capped at 1 MiB / depth 64 / 60000 nodes; errors include line and column.
FAQ
How are Date, aliases and binary values handled?
Neither YAML 1.2 nor JSON has a Date type: date-like scalars stay strings and are quoted on output. & anchors, * aliases and << merge keys are rejected (alias bombs are never expanded). Tags such as !!binary are rejected; store binary as a quoted base64 string.
Can "true" be confused with true?
No. String forms of true, null, numbers and dates are quoted, so a round-trip back to JSON keeps them strings; booleans/null are emitted unquoted.
Are multi-document streams or block scalars supported?
No. ---/... markers, |/> block scalars, directives, complex keys, non-decimal numbers and .inf/.nan produce errors with line and column, avoiding implicit expansion and numeric ambiguity.