YAML and JSON converter
Convert YAML to JSON or JSON to YAML, with clear errors and safe handling of anchors.
A clear answer. Here’s how.
Reads YAML 1.2 with the core schema using the yaml package, then writes JSON with JSON.stringify, or reads JSON strictly and writes block-style YAML. In the core schema only true and false are booleans (yes, no and on are text), 0x and 0o numbers and exponents are numbers, and dates stay as text. Anchors and aliases are expanded with a limit of 100 aliases, duplicate keys are rejected, and a stream with several documents is refused. Optional merge keys (<<, a YAML 1.1 convention) copy the merged mapping. .nan and .inf cannot be written as JSON and are reported. Comments are not carried across. Numbers beyond 15 digits lose precision as JavaScript numbers.
How this is checked
4 reference checks passed These 4 cases were run when this page was built, on 20 October 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.
See the checks and where each expected answer comes from
Case 1
- Inputs
- Direction yaml-to-jsonInput - Mark McGwire - Sammy Sosa - Ken Griffey Indent 2
- Expected, and what Toolmoz gave
- text expected [ "Mark McGwire", "Sammy Sosa", "Ken Griffey" ] , Toolmoz [ "Mark McGwire", "Sammy Sosa", "Ken Griffey" ]
- Where the expected answer comes from
- YAML 1.2 specification example 2.1, a sequence of scalars, written as JSON with two-space indent
- Allowed difference
- exact
Case 2
- Inputs
- Direction yaml-to-jsonInput american: - Boston Red Sox - Detroit Tigers - New York Yankees national: - New York Mets - Chicago Cubs - Atlanta Braves Indent 2
- Expected, and what Toolmoz gave
- text expected { "american": [ "Boston Red Sox", "Detroit Tigers", "New York Yankees" ], "national": [ "New York Mets", "Chicago Cubs", "Atlanta Braves" ] } , Toolmoz { "american": [ "Boston Red Sox", "Detroit Tigers", "New York Yankees" ], "national": [ "New York Mets", "Chicago Cubs", "Atlanta Braves" ] }
- Where the expected answer comes from
- YAML 1.2 specification example 2.3, a mapping of scalars to sequences
- Allowed difference
- exact
Case 3
- Inputs
- Direction yaml-to-jsonInput a: yes b: 0x1F c: 1e3 d: 2026-10-18 e: ~ f: 'text' Indent 0
- Expected, and what Toolmoz gave
- text expected {"a":"yes","b":31,"c":1000,"d":"2026-10-18","e":null,"f":"text"} , Toolmoz {"a":"yes","b":31,"c":1000,"d":"2026-10-18","e":null,"f":"text"}
- Where the expected answer comes from
- YAML 1.2 core schema (specification section 10.3): yes is a string, 0x1F is the integer 31, 1e3 is 1000, a date stays a string and ~ is null
- Allowed difference
- exact
Case 4
- Inputs
- Direction json-to-yamlInput {"name":"Toolmoz","tags":["a","b"],"nested":{"enabled":true}}Indent 2
- Expected, and what Toolmoz gave
- text expected name: Toolmoz tags: - a - b nested: enabled: true , Toolmoz name: Toolmoz tags: - a - b nested: enabled: true
- Where the expected answer comes from
- The same data written in block style, as in the YAML specification examples
- Allowed difference
- exact
What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- Direction
- YAML to JSON
- Input
american: - Boston Red Sox - Detroit Tigers - New York Yankees national: - New York Mets - Chicago Cubs - Atlanta Braves
- Indent
- 2 spaces
- Merge keys (<<) when reading YAML
- Apply them, as most tools do
Example result
- Keys and items converted
- 2
- Characters out
- 173
YAML 1.2 core schema: unquoted yes, no and dates stay text, anchors and aliases are expanded (at most 100 aliases), and duplicate keys are rejected. Merge keys (<<) are applied, as most tools do. Comments in YAML are not carried into JSON.