How YAML relates to JSON
YAML is a human-friendly data format built around indentation. A mapping is written as key: value lines, a list is written with a dash at the start of each item, and nesting is shown by how far a line is indented. It also allows comments, which JSON does not.
JSON describes the same kinds of data (objects, arrays, strings, numbers, booleans and null) but uses braces, brackets, quotes and commas. In fact most JSON is also valid YAML. Because the two formats share the same data model, a document can usually be moved from one to the other without losing information, as long as it does not rely on YAML-only features like comments or anchors.
Why you would convert YAML to JSON
Configuration files for containers, CI pipelines, Kubernetes and many frameworks are written in YAML because it is easy to edit by hand. Tools, scripts and APIs, on the other hand, usually expect JSON. Converting lets you feed a YAML config into something that only accepts JSON, or look at how a YAML file is really parsed.
It is also a good debugging step. YAML is sensitive to indentation, and a value that looks like a string to you may be read as a number or boolean. Seeing the JSON result shows exactly what a parser understood: whether a list is really a list, whether a value is quoted, and whether a key landed at the level you intended. Once you have JSON, the JSON Formatter or the JSON Validator can help you check it further.
How to use this converter
- Paste your YAML into the YAML box. It starts with a small example (a name, a boolean and a list of tags).
- The JSON box below updates automatically as you type, formatted with two-space indentation.
- If the YAML cannot be parsed, an error message from the parser appears instead of output. Fix the indicated problem and the result returns.
- Click Copy to copy the JSON.
The page on this site converts in one direction only: YAML in, JSON out. Parsing is done with a YAML library loaded into your browser, and your text is not uploaded anywhere. There is no download button.
Pitfalls when converting
Indentation must use spaces, not tabs, and sibling items must line up exactly. The most common error is a list or key indented one space off from its neighbors.
Watch for values YAML interprets on its own. Unquoted words like yes, no or true may become booleans, an unquoted 010 or 1.0 may become a number, and an empty value becomes null. If you need text kept as text, put quotes around it in the YAML. Check the JSON output to confirm the types are what you expect.
Comments in the YAML are dropped because JSON has no place for them. If your file contains several documents separated by three dashes, the parser used here expects a single document, so convert them one at a time. Spreadsheet-style data is a different problem, and for that the CSV to JSON tool is the better fit.