About the YAML to JSON Converter
This tool converts YAML to JSON and JSON to YAML in your browser. It uses js-yaml with the YAML 1.2 core schema, so yes and on stay strings, dates stay text, and custom tags like !!js/function are rejected instead of run. Merge keys (<<: *defaults) and anchors are expanded, and mapping keys keep the order they were written in, in both directions.
A file with several documents separated by ---, such as a Kubernetes manifest, becomes a JSON array with one item per document. Going back, tick Top-level array as separate documents to write each item as its own document again.
How to use it
- Choose YAML → JSON or JSON → YAML and paste your input, or click Load sample.
- Pick the indent: 2 or 4 spaces, or a tab for JSON.
- If the input is invalid, the error gives the line and column and shows the offending lines.
- Select Swap to use the output as the new input, and copy or download the result.
Examples
- Convert a small config:
yesstays the string"yes"under YAML 1.2. - Turn two documents into an array: the output is a JSON array of two objects.
- Find an indentation error: the error points at line 3.
Common questions
Why are some values quoted in the YAML output?
Strings that another parser could read as a number, boolean or null, such as '1.0', 'yes' or 'no', are quoted so they stay strings in YAML 1.1 tools too.
Are comments kept?
No. JSON has no comments, so they are dropped when converting from YAML.
Is JSON valid YAML?
Almost always: YAML 1.2 is a superset of JSON, so you can paste JSON on the YAML side as well.
Related tools
- JSON Formatter & Validator: format or minify the result.
- JSON to TypeScript & Go Types: generate types from your config.
- Text Diff Checker: compare two versions of a file.