Skip to content

YAML to JSON Converter - Convert YAML to JSON Online

Input YAML
JSON Output

Convert YAML to JSON

Paste YAML on the left and formatted JSON appears on the right. Use it to feed a config file to an API or script that only takes JSON, or to see exactly how a parser reads your YAML. Indentation mistakes and surprising types are much easier to spot in JSON, where every string has quotes and every nesting level has braces. Parsing happens in your browser.

Example

version: 1.10
zip: 012
country: NO
release: 2024-01-05
base: &base
  image: node
web:
  <<: *base
  port: 80

converts to:

{
  "version": 1.1,
  "zip": 12,
  "country": "NO",
  "release": "2024-01-05",
  "base": { "image": "node" },
  "web": { "image": "node", "port": 80 }
}

The version and ZIP code lost their formatting because unquoted they are numbers. NO and the date stayed strings under YAML 1.2 rules, and the merge key copied image into web. (The real output puts each key on its own line.)

Parsing Details

  • Block and flow styles, quoted and block scalars (|, >) and multi-line strings are all supported.
  • Integers larger than 253 are kept exact rather than rounded.
  • Syntax errors, such as a tab used for indentation, are reported with the line and column instead of producing partial output.
  • A missing space after a colon is not an error: key:value is read as the single string "key:value". If a key disappears from the output, look for this.
  • Custom tags such as !Ref in CloudFormation templates are dropped and only the value is kept, so !Ref MyBucket becomes "MyBucket".

To go the other way, use the JSON to YAML converter. To explore a large result, paste it into the JSON tree viewer.

Related Tools

Frequently Asked Questions

Does the converter handle anchors, aliases and merge keys?
Yes. Anchors (&name) and aliases (*name) are expanded, and merge keys (<<: *name), common in Docker Compose and GitLab CI files, are merged into the target mapping. The JSON shows the fully expanded result.
Can I convert a file with several documents?
Yes. Documents separated by --- become a JSON array with one element per document, so a combined Kubernetes manifest with a Deployment and a Service gives a two-item array. A single document gives a plain object.
Why did my version number 1.10 turn into 1.1?
Unquoted, 1.10 is a number in YAML, and 1.10 and 1.1 are the same number. The same thing turns zip: 012 into 12. Quote values that are really strings ("1.10", "012") in the YAML and they come through unchanged.
Will yes, no and on become booleans?
No. The parser follows YAML 1.2, where only true and false are booleans, so yes, no, on and country codes like NO stay strings. Dates such as 2024-01-05 also stay strings. PyYAML and other YAML 1.1 parsers would treat these differently, so a file can mean different things to different tools.
Are YAML comments kept in the JSON?
No. JSON has no comment syntax, so comments are dropped. Everything else, including key order, is preserved.