YAML to JSON

Convert a YAML 1.2 Core document to JSON, or JSON back to YAML.

Docify's YAML tool converts one document in your browser with js-yaml 5. YAML → JSON calls load with CORE_SCHEMA (YAML 1.2 Core), then JSON.stringify with 2-space indent. JSON → YAML calls JSON.parse, then dump with the same schema, 2-space indent, unlimited line width, and noRefs. Convert is a button, not as-you-type. Empty streams, extra --- documents, and duplicate keys throw. Comments are dropped. yes / NO stay strings. Not YAML 1.1, not a linter, and not Kubernetes validation. Nothing is uploaded.

YAML
JSON output

How it works

  1. Convert is a button, not as-you-type. Load sample fills the input only. Copy writes the output. Nothing is uploaded.
  2. YAML → JSON uses load with CORE_SCHEMA, then JSON.stringify(..., null, 2). JSON → YAML uses JSON.parse, then dump with indent: 2, lineWidth: -1, noRefs: true, and the same schema.
  3. One document only. Empty input and extra --- documents throw. Duplicate keys throw. Comments are dropped. Anchors expand to copies. .inf / .nan become JSON null.
  4. This is not YAML 1.1 (no Norway-problem booleans), not !!merge, not a comment- preserving pretty-printer, and not a Kubernetes or JSON Schema validator.

FAQ

Does this converter upload my YAML or JSON?
No. Convert and copy run in your browser with js-yaml 5 and JSON.parse / JSON.stringify. The page does not send the text to a server.
Which YAML dialect does this page parse?
js-yaml 5 load with CORE_SCHEMA — YAML 1.2 Core. true/false/null (and ~) are typed; yes, no, and NO stay strings, so the YAML 1.1 Norway problem does not apply. Dates such as 2026-08-20 stay strings. !!merge (<<) is not enabled, so a << key is just a key. This is not YAML 1.1, not Kubernetes validation, and not a schema linter.
What does Convert reject or drop?
load accepts one document. Empty input, a whitespace-only stream, and multi-document streams (---) throw. Duplicate mapping keys throw. Comments are discarded. Anchors are expanded into copies. JSON.stringify turns YAML .inf and .nan into null because JSON has no Infinity or NaN. JSON → YAML uses JSON.parse, so comments, trailing commas, and single quotes are rejected.
Does a round trip keep comments, anchors, or key style?
No. Comments never survive load. dump writes CORE_SCHEMA YAML with 2-space indent, unlimited line width, and noRefs so duplicate objects are inlined rather than aliased. Quote style and original key order are not a formatter guarantee. This is not a YAML pretty-printer that preserves source text.

Related