YAML to JSON Converter

Convert YAML markup to JSON format

About This Tool

You have a YAML file and the API you're working with only takes JSON. Or you've copied a Kubernetes manifest from a blog post and need to inspect what it actually expands to before running it. The two formats represent the same data structures, but the conversion has enough small gotchas — quoted vs unquoted strings, multi-line values, anchor references — that doing it by hand at any size is asking for trouble.

Paste YAML in, get JSON out. The converter handles anchors and aliases (the &foo and *foo syntax), block-style and flow-style collections, and the YAML 1.2 type tagging. Common quirks like the "Norway problem" (where the unquoted country code NO became the boolean false) are handled the modern way — strings stay strings unless they're explicitly typed.

The core difference between the formats: YAML has features JSON doesn't (anchors, comments, multiple documents per file, type tags). JSON has features YAML doesn't (an actual spec people agree on). YAML 1.2 was the version that fixed most of the worst behaviors from earlier versions, including the unquoted-string-becomes-boolean problem. The converter parses according to YAML 1.2 rules: bare "yes" stays as the string "yes" (it doesn't become true), bare "on" stays as the string "on", and explicit type tags like !!str force string interpretation. Anchors get resolved into copies of the referenced data, which expands the JSON output beyond the YAML's compact form.

A worked example: paste in a YAML doc with `default: &default {timeout: 30, retries: 3}` and `service: <<: *default, name: api`. The merged map syntax (<<:) brings in default's fields, and the JSON output expands to {"default": {"timeout": 30, "retries": 3}, "service": {"timeout": 30, "retries": 3, "name": "api"}}. The anchor saved typing in the YAML; JSON requires the duplication. Now you can pipe the output into a curl request that needs JSON.

The limitations worth knowing: JSON has no comments, so YAML comments are stripped on output. JSON has no concept of multiple documents in one file, so a multi-doc YAML file gets only its first document converted by default — wrap them in a JSON array if you need all of them. JSON's number type is double-precision float, so very large integers (above 2^53) lose precision. Some YAML producers emit timestamps as native types; JSON doesn't have a timestamp type, so they convert to ISO 8601 strings. If your downstream consumer expects native datetime objects, parse them back from the string on the receiving end. Round-tripping YAML through JSON loses anchors, comments, type tags, and multi-doc structure — it's a one-way trip for most use cases.

The about text and FAQ on this page were drafted with AI assistance and reviewed by a member of the Coherence Daddy team before publishing. See our Content Policy for editorial standards.

Frequently Asked Questions