YAML to JSON Converter

Paste YAML and get structured JSON — types preserved, lists and nested mappings handled. Or flip the direction and turn JSON into clean YAML. All in your browser.

How YAML to JSON Conversion Works

YAML and JSON are close relatives — JSON is nearly a subset of YAML — so this conversion is mostly about reading structure faithfully. The parser reads indentation to rebuild the tree: lines at the same indent are siblings, deeper indentation means children, and dashes mark list items. Unlike XML, YAML scalars carry types, so the converter honours them: an unquoted 2016 becomes the JSON number 2016, true becomes the boolean true, and a quoted "2016" stays a string, exactly as the author intended.

Keys keep their document order, sequences become arrays, and a dash followed by indented key: value pairs — YAML's standard way of writing a list of records — becomes an array of objects. Comments are dropped, because JSON has nowhere to put them. The converter covers the block-style YAML that configuration files are actually written in; the full specification's exotic features (anchors, aliases, custom tags) are out of scope, and the FAQ below says so plainly rather than failing mysteriously on them.

Worked Example: A Bakery's Data File, Converted

The sample above is a small business record in YAML. Converted, it produces this JSON (exact content, lightly arranged):

{
  "name": "Riverside Bakery",
  "founded": 2016,
  "rating": 4.8,
  "open": true,
  "tags": [
    "bread",
    "cakes"
  ],
  "menu": [
    { "item": "Sourdough loaf", "price": 6.5 },
    { "item": "Butter croissant", "price": 3.75 }
  ]
}

Watch what the types do. founded stays a number (2016), rating stays a decimal (4.8), and open becomes a proper JSON boolean — none of them quoted. The prices show the one transformation to expect: 6.50 arrives as 6.5, because both are the same number and JSON writes numbers in their shortest form; quote a price in the YAML if its trailing zero is information rather than arithmetic. The two menu entries — written in YAML as dashes with indented keys — become an array of two objects, ready for any program that consumes JSON. Switch the direction toggle and the same panel will turn JSON back into YAML you can edit by hand. For XML data instead, the XML to JSON Converter applies the same in-browser approach with XML's own mapping rules.

Where This Conversion Earns Its Keep

The everyday trigger is a tool boundary: a Kubernetes manifest, GitHub Actions workflow, docker-compose file or application config exists as YAML, but the script, API or test fixture consuming it wants JSON. Converting locally — in the browser, with nothing uploaded — matters more here than with most formats, because configuration files describe your infrastructure: hostnames, paths, ports and service names. They should not be pasted into a server-side converter, and with this page they do not have to be.

Frequently Asked Questions

Which YAML does this converter support?

The block-style YAML used in real configuration files: nested mappings by indentation, sequences with dashes, scalars (strings, integers, decimals, booleans, null), quoted strings, flow collections like [1, 2] and {a: b}, comments, and literal/folded block text (| and >). Exotic corners of the full YAML specification — anchors and aliases, custom tags, multi-document streams — are not supported; if your file uses them, it needs a full YAML library instead.

Why did my number 6.50 come out as 6.5?

Because YAML scalars have real types, unlike XML. An unquoted 6.50 is a decimal number, and JSON writes that number in its shortest exact form: 6.5. The value is identical. If the trailing zero matters (product codes, fixed-format prices), quote the value in your YAML — "6.50" — and it will be converted as a string and keep its formatting.

How are YAML lists converted?

A YAML sequence becomes a JSON array, in order. Items can be scalars (the tags list in the worked example) or mappings — a dash followed by indented key: value pairs becomes an object inside the array, which is how lists of records like menus, steps and hosts are normally written in YAML.

Can I convert JSON back to YAML?

Yes — switch the direction toggle above the editor. The same page turns JSON into clean block-style YAML with two-space indentation, which is handy for hand-editing configuration that a program produced as JSON. Converting the result back should return the same data, which is also a quick way to sanity-check a conversion.

What does an indentation error look like?

YAML is whitespace-sensitive: a key indented by the wrong number of spaces quietly belongs to a different parent, or breaks the structure outright. If the JSON output has a key nested somewhere unexpected, check the spaces (not tabs — YAML forbids tabs for indentation) on the lines above it. The converter reports what it could not make sense of rather than guessing silently where it can.

Is my YAML uploaded anywhere?

No. Parsing happens in your browser with code on this page, so configuration files — which often contain hostnames, paths and the shape of your infrastructure — never leave your machine. Nothing is uploaded, stored or logged.