Because YAML 1.2.2 was designed as a superset of RFC 8259 JSON, every valid JSON document maps cleanly to YAML block mappings, sequences, and scalars. This converter transforms strict JSON payloads into human-readable block-style YAML using JSON.parse followed by yaml.stringify. You can customize the indentation spacing and optionally sort object keys recursively.
For instance, converting this JSON snippet:
{
"version": "1.0",
"services": {
"web": {
"ports": ["80:80"]
}
}
}
produces the following YAML output:
version: "1.0"
services:
web:
ports:
- "80:80"
Notice that string values that resemble numbers or ratios (such as "1.0" and "80:80") retain their quotes in the YAML output so downstream parsers do not misinterpret them as floats or base-60 integers.