# YAML to JSON converter

Paste YAML to get JSON, or JSON to get YAML; the direction is detected. Numbers keep every digit, keys keep their order, and what cannot be converted exactly is named with its line. Nothing is uploaded.

Page: https://toolkitnow.org/tools/yaml-to-json/

Paste YAML to get JSON, or JSON to get YAML. The gray text is an example.

## Good to know

### Which way

Text that starts with `{` or `[` is read as JSON and written as YAML; anything else is read as YAML and written as JSON. YAML written in that style (`{a: 1}`) is read as YAML when it is not JSON, and the page says so.

### Numbers

Kept digit for digit: `12345678901234567890` is not rounded. YAML forms JSON lacks become plain numbers (`0x1F` is 31, `.5` is 0.5). `.inf` and `.nan` have no JSON form, so the page says where they are. A JSON `1e5` is written `1.0e+5`, which every YAML reader takes as a number.

### Text that looks like a value

In the YAML written, text such as `yes`, `no`, `on`, `12:30` or `2024-01-01` is quoted: older YAML readers (YAML 1.1, as in PyYAML) would take it for a boolean, a number or a date; `null` and `true` are quoted too. Read from YAML, `yes` and `no` stay text, as YAML 1.2 says.

### Keys

Kept in their order. A key that appears twice in one map is an error in YAML, so the page names its line rather than keep one of the values silently. A plain key is read as YAML reads it (`True` becomes `"true"`); a number key that readers would write differently (`0x10`, `1.0`) or a null key is named, to be quoted.

### Not supported

Anchors and aliases (`&`, `*`, `<<`), tags such as `!Ref`, several documents in one file, a `%YAML 1.1` file, tabs in the indentation, quoted or plain text that runs over several lines, and an unquoted value with a quoted part that holds ` #  ` or ` :  ` are named with their line instead of being converted with data missing. Comments are left out: JSON has none.

### Open from a link

`?input=port%3A%208080` opens the page with that text; add `&indent=4`.

Runs in the browser; nothing is uploaded. Part of toolkitnow.org.
