Skip to content
UniKit

YAML to JSON

Convert YAML to JSON with the YAML 1.2 core schema: anchors and aliases are expanded, and nested mappings, flow arrays and block scalars are all supported. Parsing stays in your browser.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

YAML input

Parsed with the YAML 1.2 core schema (yes/no/on stay strings) and anchors/aliases are expanded. Multi-document streams (---) are not supported.

JSON output

Parsed with js-yaml load and serialised as JSON with two-space indentation.

Paste YAML to see the JSON

What this tool does

  • Convert a CI or Kubernetes YAML config into JSON so jq or a program can read it
  • Turn a YAML sample from API docs into JSON for a test fixture

Example

Input

server:
  host: 127.0.0.1
  ports: [8080, 8443]

Output

{
  "server": {
    "host": "127.0.0.1",
    "ports": [
      8080,
      8443
    ]
  }
}

Indented blocks and flow arrays are both parsed correctly.

Frequently asked questions

Do yes / no / on become booleans?

No. This tool uses the YAML 1.2 core schema where only true and false are booleans, so yes, no and on stay strings. Configs relying on YAML 1.1 booleans may convert differently.

Are multi-document streams supported?

No. A second document raises a parse error; split the file into single documents first.

Are anchors, aliases and merge keys kept?

Anchors (&x) and aliases (*x) are expanded into independent copies, so the JSON contains no references, and merge keys << are merged into the object.

What about number precision?

YAML literals such as 0x10, 1e3 and 012 are parsed as 16, 1000 and 12. Integers above 2^53-1 become doubles during parsing and lose precision.

Keywords:yaml to jsonjs-yaml

Related tools