What is YAML to JSON Converter?

YAML to JSON Converter turns YAML documents into equivalent JSON structures instantly. It handles anchors, aliases, multi-line strings, nested maps, and sequences, so you can convert Kubernetes configs, CI/CD pipelines, or other YAML data into JSON for APIs and code.

Built on js-yaml, the converter understands YAML 1.2 features that catch many simple converters out: anchors and aliases (&ref / *ref), multi-line block strings (|, >), explicit type tags, and the boolean variants like yes/no/on/off. A reverse mode lets you go back from JSON to YAML, preserving structure while collapsing arrays of scalars onto one line where it reads better.

How to use

  1. Step 1 — Paste YAML content or upload a .yml/.yaml file. Syntax errors are highlighted with line numbers for quick fixes.
  2. Step 2 — View the converted JSON output with configurable indentation: 2 spaces, 4 spaces, tabs, or compact.
  3. Step 3 — Copy the JSON or download it as a .json file. Use the reverse mode to convert JSON back to YAML.

When to use

  • Translating a Kubernetes manifest or Helm values file to JSON for a custom validator script.
  • Feeding GitHub Actions or GitLab CI config into a tool that only accepts JSON pipelines.
  • Switching docker-compose.yml between YAML and JSON forms while debugging Compose schema errors.

Result

You need to convert a docker-compose.yml to JSON for a deployment API. Paste the YAML with its services, volumes, and network definitions, and you get valid JSON the API accepts, with every nested structure and array intact.

FAQ

Does the converter handle YAML anchors and aliases (& and *)?
Yes. js-yaml resolves anchors during parsing, so the output JSON contains the expanded values instead of the reference syntax. If two keys shared an anchor in YAML, they each get their own copy of the data in the JSON output.
Why does my YAML boolean (yes / no) come out as a string in some tools?
YAML 1.1 treated yes/no/on/off as booleans, but YAML 1.2 only recognises true/false. This converter follows YAML 1.2, so yes/no stay strings unless you quote them as booleans explicitly. That's why Norway and other gotchas usually disappear here.
Can I convert JSON back to YAML?
Yes. Flip the reverse toggle and the input becomes JSON, the output YAML. The dumper preserves nested objects and arrays, and large keys with newlines render as block scalars (|) so they stay readable.
How are dates and timestamps handled?
YAML date and timestamp literals become ISO 8601 strings in JSON (since JSON has no native date type). Round-tripping through the reverse mode keeps them as strings rather than restoring the implicit YAML date type, which is the safer default.
What's the indent option for, and which should I pick?
2 spaces is the de facto standard for JavaScript and most APIs. 4 spaces matches Python's PEP 8 if you'll embed the result in a .py file. Compact (0) gives single-line output ideal for HTTP request bodies or copying into a curl command. Tab indents JSON with a real tab character, handy for Go or Makefiles; YAML can't use tabs, so reverse mode falls back to 2 spaces.

Related Tools