yaml to json converter

typetools

instant, client-side type converter • 0ms network latency

root:
165 chars
{
  "service": "typetools-edge-worker",
  "version": 2,
  "runtime": "cloudflare-pages",
  "replicas": 3,
  "debug": false,
  "limits": {
    "memoryMb": 128,
    "timeoutMs": 50
  },
  "regions": [
    "iad",
    "sfo",
    "fra"
  ]
}
0.15ms•in-browser
documentation, edge cases & specifications below

step-by-step integration guide

technical specification differences & end-to-end conversion workflow

Architectural Differences Between YAML 1.2 and RFC 8259 JSON

While YAML 1.2 is officially a superset of JSON, the two serialization formats rely on fundamentally different lexical grammars and AST resolution passes. YAML utilizes indentation-based scoping, off-side rule tokenization, and implicit scalar tag resolution (such as Core Schema vs. Failsafe Schema), whereas RFC 8259 JSON enforces strict delimiter-based grammar using braces, brackets, and double-quoted UTF-8 strings. Furthermore, YAML supports relational graph structures via node anchors (&anchor), alias dereferencing (*alias), and merge keys (<<:), which have no native representation in a hierarchical JSON syntax tree. When converting complex DevOps manifests—such as Kubernetes deployments, Docker Compose stacks, or GitHub Actions workflows—a naive regex parser will corrupt multi-line literal block scalars (|) and folded block scalars (>).

How the AST Resolution Pipeline Converts YAML to JSON

To convert YAML to JSON deterministically without data loss, our client-side parser executes a three-stage compilation pass inside an isolated Web Worker. First, the lexer scans indentation levels and strips inline comments (#), which JSON explicitly forbids. Second, the parser constructs a directed representation graph and resolves all YAML anchors and alias references by deep-cloning the target subtrees into their respective consumer nodes, preventing circular reference infinite loops. Third, scalar values are evaluated against YAML 1.2 Core Schema rules rather than legacy YAML 1.1 rules—preventing the infamous "Norway Problem" where unquoted country codes like NO or off are coerced into boolean false. Finally, multi-line strings are normalized with escaped newline sequences (\n) and serialized into deterministic, pretty-printed JSON with 2-space indentation.

frequently asked questions

common developer questions answered

q:How does the converter handle YAML anchors (&) and aliases (*) when outputting JSON?

Because JSON does not support internal pointer references or aliases, the parser resolves all anchors during AST traversal and flattens them by deep-copying the referenced object properties directly into every target node before serializing to JSON.

q:Does this tool prevent the YAML 1.1 'Norway Problem' boolean coercion?

Yes. By adhering strictly to the YAML 1.2 Core Schema specification, unquoted strings like NO, Yes, On, and Off remain string literals unless explicitly typed as true or false, preserving ISO country codes and hexadecimal strings.

q:What happens to YAML comments and multi-document streams (---) during conversion?

Since RFC 8259 JSON disallows comments, all # comment tokens are stripped during lexical analysis. Multi-document YAML streams separated by --- are automatically wrapped into a top-level JSON array so every document is preserved.

topic cluster

related type & ast converters

3 interconnected tools