esc
YAML → JSON

YAML to JSON:
Converter

YAML to JSON. Free, private, instant.

Reverse JSON → YAML

How to convert YAML to JSON

  1. 01Add YAML filesChoose files or drop them on the page.
  2. 02Converted on your deviceNothing is uploaded. Adjust settings if you like.
  3. 03DownloadSave each file, or all of them as one ZIP.

This YAML to JSON converter is for the moments a script, API or tool wants JSON: a Kubernetes manifest, a Docker Compose file, a CI pipeline or an OpenAPI spec you want to read in code. Drop a .yaml or .yml file, choose an indent, and the JSON is built in your browser, so config files with internal hostnames or keys never leave your device.

What the JSON looks like

Mappings become objects, lists become arrays and keys keep their order. A file with name: web, replicas: 3 and a ports list of - 80 and - 443 becomes {"name": "web", "replicas": 3, "ports": [80, 443]}.

Multi-line text is handled the YAML way. A literal block (|) keeps its line breaks, which appear as \n in the JSON string. A folded block (>) joins its lines with spaces.

The Indent setting gives you 2 spaces (the default), 4 spaces or Minified, which puts everything on one line for the smallest file.

Booleans, dates and numbers follow YAML 1.2

Older YAML tools use the 1.1 rules, where a lot of plain words have special meaning. This converter follows the newer YAML 1.2 rules, which are stricter and usually what you want:

  • yes, no, on and off stay strings. Only true and false become JSON booleans.
  • Dates stay strings, so 2024-01-15 comes out as "2024-01-15" rather than a timestamp.
  • Numbers become JSON numbers, and that can surprise you: an unquoted version like 1.10 becomes 1.1, and 012 becomes 12. Quote values such as versions and postal codes to keep them exactly as written.
  • 0x1F is read as a hexadecimal number (31).
  • ~, null and an empty value (key:) all become null.
  • Integers larger than about 9 quadrillion lose precision, as they do anywhere in JavaScript.

Anchors, merge keys and multiple documents

  • Anchors and aliases (&base and *base) are expanded. Every alias becomes a full copy of the anchored value, since JSON has no references.
  • Merge keys (<<: *base), common in Docker Compose and CI files, are not merged. They come through as a literal key named "<<" holding the anchored values, so check the output if your file uses them.
  • A file with several documents separated by --- becomes a JSON array with one entry per document, which suits Kubernetes files that define several resources. A single document becomes a plain object.
  • Comments are dropped, because JSON can’t hold them. A file that contains nothing but comments gives null.

Errors and how to fix them

To go back, JSON to YAML rebuilds readable YAML, though comments and anchors from the original can’t be restored.

  • “This isn’t valid YAML (line 4, column 3)”. The message points to where parsing stopped. Look at that line and the one above it.
  • Tabs. YAML only allows spaces for indentation, and a tab is rejected. Replace tabs with spaces in your editor.
  • Duplicate keys. Two identical keys in the same mapping are an error here, instead of the last one silently winning.
  • Inconsistent indentation. Items of the same list or mapping must line up exactly.

At a glance

Price
Free. No sign-up, no watermark.
Privacy
Files are processed in your browser and never uploaded.
Accepts
YAML, YML
You get
JSON
Batch
Convert many files at once and download them as a ZIP
Works in
Chrome, Edge, Firefox and Safari, on phones and computers
Offline
After the first conversion, it keeps working without internet

Questions

Are my files uploaded?

Never. YAML to JSON conversion runs in your browser, so your files stay on your device.

Can I convert many at once?

Yes. Add as many as you like and download them all as one ZIP.

Is there a size limit?

Files of tens of megabytes are fine on most computers.

Why did “on” or “yes” stay a string?

The converter follows YAML 1.2, where only true and false are booleans. Change the value to true or false if you mean a boolean.

Can it convert a file with several Kubernetes resources?

Yes. Documents separated by --- become an array, one entry per resource.

Are .yml and .yaml files both accepted?

Yes. They are the same format with two common file endings.

Does it check that my YAML is valid?

Yes. Invalid YAML is rejected with the line and column where the problem was found.

How do I convert a Swagger YAML file to JSON?

Drop the swagger.yaml or openapi.yaml file here and save the result. The spec is ordinary YAML, so paths, schemas and $ref entries come through as normal JSON keys and strings. References are copied as they are, not resolved.