Free YAML to JSON Converter

Convert YAML to JSON in your browser: paste YAML or open a .yaml or .yml file, choose pretty or minified output, and press Convert to JSON. Copy the result or download it as a .json file. Your data never leaves your device. Going the other way? Use the JSON to YAML converter.

100% Private & Secure: All YAML to JSON conversion happens in your browser. Your data never leaves your device and is never sent to any server.

Options
0 characters

Supports comments, multi-line strings, anchors (&), aliases (*), merge keys (<<) and document separators (---).

How YAML values become JSON

  • โ€ข Parsed with js-yaml as YAML 1.2: true/false are booleans, yes/no/on/off stay strings unless you turn on YAML 1.1 booleans.
  • โ€ข Several documents separated by --- become a JSON array; anchors, aliases and merge keys (<<) are expanded.
  • โ€ข Dates such as 2024-01-15 stay exactly as written; !!binary stays a Base64 string.
  • โ€ข Integers too large for JavaScript numbers keep all their digits; .inf and .nan become null with a warning.
  • โ€ข CloudFormation tags such as !Ref and !Sub become {"Ref": ...} and {"Fn::Sub": ...}; other custom tags are dropped and their values kept, with a warning.

Summary

A YAML to JSON converter reads a YAML file and writes the same data as JSON, which APIs, JavaScript and most tooling accept. To convert YAML to JSON free and privately here, paste your YAML into YAML Input, or click Open YAML File or Load Sample, choose Pretty print (2 spaces) or Minified (one line), click Convert to JSON, then click Copy or Download JSON. The tool runs in your browser and nothing is uploaded; you can check the Network tab in DevTools. It follows YAML 1.2 and handles multi-document files, anchors, aliases, merge keys, block scalars and CloudFormation tags.

Two rules explain most surprises. Only true and false are booleans, so yes, no, on and off stay strings unless you tick YAML 1.1 booleans. And several documents separated by --- become one JSON array. Comments are dropped because JSON has none, and the result is checked only for valid YAML syntax, not against a schema such as Kubernetes or CloudFormation.

Table of Use: YAML In, JSON Out

How YAML constructs are converted to JSON, and which option changes the result
YAMLSettingJSON result
port: 8080, debug: true, x: nullDefault"port": 8080, "debug": true, "x": null
date: 2024-01-15Default"date": "2024-01-15", a string exactly as written
enabled: yesDefault, or YAML 1.1 booleans ticked"enabled": "yes", or "enabled": true
Two documents separated by ---DefaultAn array of two objects, in order
<<: *defaults in a mappingDefaultThe anchored keys are copied in; keys you wrote yourself win
A | block and a > blockDefault"line1\nline2\n" and the folded "folded text\n"
id: 12345678901234567890DefaultAll 20 digits kept, plus a Check these values warning
ratio: .infDefault"ratio": null and a warning naming the path
Name: !Ref BucketDefault"Name": { "Ref": "Bucket" }
A tab in the indentationDefaultAn Invalid YAML panel: Line 2, column 1: tab characters must not be used in indentation

Worked example: with Load Sample, the 38-line library file becomes 1 document and 1.11 KB of pretty-printed JSON, or 669 bytes when you choose Minified (one line). The YAML Lines, Documents and Output Size cards show these figures for your own file.

Features

  • Two options. Output Style (Pretty print with 2 spaces, or Minified on one line) and the YAML 1.1 booleans checkbox for files written for older parsers such as Ansible. Changing an option updates the result at once.
  • Anchors, aliases and merge keys expanded. Aliases become copies. If expanding them would give more than 10 million values, or an anchor contains itself, the tool stops with an error instead of freezing your browser.
  • Types kept sensibly. Hexadecimal, octal and binary integers become numbers, !!binary stays a Base64 string, and a number too large for JavaScript keeps all its digits. .inf and .nan become null, because JSON cannot hold them, and the tool warns you.
  • CloudFormation short forms. !Ref, !Sub, !GetAtt, !Join, !If, !Equals, !Select and the other functions the tool knows are written in their JSON long form. Any other custom tag keeps its value and loses the tag, with a warning.
  • Clear errors. Invalid YAML shows the line, the column and the offending lines. A file with only comments or --- markers says that no YAML content was found.
  • Files. Open YAML File accepts .yaml, .yml and .txt, and you can drop a file on the input. UTF-8 and UTF-16 (with a byte order mark) are read. A download is named after the file (config.yml becomes config.json), or converted.json for pasted YAML.

Limits: mapping keys that look like whole numbers are listed first in ascending order, because JavaScript objects order them that way, so b: 1 followed by 10: x and 2: y comes out as "2", "10", "b". A very large result is shown only up to 2,000,000 characters, while Copy and Download JSON give everything. The conversion is one way; to write JSON as YAML use the JSON to YAML converter. The js-yaml parser is fetched from this site the first time you convert.

How to Use the YAML to JSON Converter

  1. Paste your YAML into YAML Input, drop a file on it, or click Open YAML File. Load Sample fills in an example.
  2. Choose Output Style: Pretty print (2 spaces) or Minified (one line). Tick YAML 1.1 booleans if yes, no, on and off should become true and false.
  3. Click Convert to JSON. Opening a file or loading the sample converts at once. If you see Invalid YAML, fix the line it names and convert again.
  4. Read JSON Output and any Check these values warnings. Option changes apply immediately; after editing the YAML, click Convert to JSON again.
  5. Click Copy or Download JSON. Clear All empties the page.

Who Can Use It

DevOps engineers can turn a Kubernetes manifest, a Docker Compose file or a CI pipeline into JSON for a script or an API call. Cloud engineers can convert a CloudFormation template to the JSON form. Developers can load YAML settings in code that only reads JSON, and tidy the result with the JSON formatter, check it with the JSON validator or shrink it with the JSON minifier.

Working with other formats? Convert XML with the XML to JSON converter or go back with the JSON to XML converter, turn spreadsheets into JSON with the CSV to JSON converter and flatten JSON into a table with the JSON to CSV converter. Pipeline files often hold schedules, which the cron expression generator helps you write.

FAQs

How do I convert YAML to JSON online?

Paste your YAML into YAML Input, or click Open YAML File or Load Sample. Choose Pretty print (2 spaces) or Minified (one line), click Convert to JSON, then click Copy or Download JSON. Opening a file or loading the sample converts at once. The tool runs in your browser and nothing is uploaded; you can check the Network tab in DevTools.

Which YAML version does the converter follow?

YAML 1.2, parsed with the js-yaml library: only true and false are booleans, while yes, no, on and off stay strings. If your file was written for a YAML 1.1 parser, such as Ansible or older PyYAML-based tools, tick YAML 1.1 booleans and yes/no/on/off become true/false. Merge keys (<<) from YAML 1.1 are always supported.

How are multi-document files such as Kubernetes manifests converted?

Every document separated by --- becomes one item of a JSON array, in order, so a manifest with a Service and a Deployment becomes an array of two objects. A file with a single document becomes a single JSON value. Anchors are local to their document, as the YAML specification requires, and the Documents card shows the count.

What happens to anchors, aliases and merge keys?

They are resolved: every *alias is replaced by a copy of the anchored value, and <<: *defaults merges the keys of the anchored mapping, with keys written in the mapping itself taking priority. A recursive anchor, or aliases that would expand to more than 10 million values, is reported as an error instead of freezing your browser.

Are dates, big numbers and special values converted correctly?

Dates such as 2024-01-15 stay exactly as written, as JSON strings. Integers larger than 9,007,199,254,740,991 keep all their digits instead of being rounded, with a warning because JavaScript's JSON.parse would round them. Hexadecimal, octal and binary integers become ordinary numbers. JSON has no infinity or NaN, so .inf and .nan become null and are listed in a warning.

Can I convert CloudFormation templates?

Yes. Short-form functions become the JSON long form: !Ref Bucket becomes {"Ref": "Bucket"}, !Sub becomes {"Fn::Sub": ...}, !GetAtt Role.Arn becomes {"Fn::GetAtt": ["Role", "Arn"]}, and the same for !Join, !If, !Equals, !Select and the other supported functions. Other custom tags have no JSON equivalent, so their values are kept and the tags are listed in a warning.

What if my YAML is invalid?

You get an Invalid YAML panel with the parser's message, the line and column and the offending lines marked. Common causes are tab characters in indentation, a key that appears twice in the same mapping, inconsistent indentation and an unclosed quote. A file with only comments and --- markers reports that no YAML content was found.

Is my YAML uploaded anywhere?

No. This tool runs in your browser and nothing is uploaded; you can check the Network tab in DevTools. The first conversion downloads the js-yaml parser as part of this site's own JavaScript, but your YAML is not part of any request, so configuration files, secrets and credentials stay on your device.