webtools

YAML to JSON Converter

Private: nothing leaves your browser

JSON
output

                  

Paste YAML on the left and the JSON appears on the right.

Paste a Compose file, a CI pipeline or a Kubernetes manifest and get the JSON equivalent as you type, with the line number named when something will not parse. Your config is converted on your own device, so credentials in it stay with you.

About converting YAML to JSON

YAML and JSON describe the same shapes: mappings, sequences, strings, numbers, booleans and null. YAML is the one people write by hand because the indentation replaces most of the punctuation, and JSON is the one programs read because there is only one way to spell anything. Converting between them is how you get a hand-written config into a tool that only accepts JSON, or how you check what a fiddly piece of YAML actually means.

The conversion runs on this page. Nothing is uploaded, which matters more than usual here: config files are exactly where API keys, connection strings and internal hostnames tend to live. It also means the converter keeps working with your connection switched off.

Comments are the one thing JSON cannot carry, so they are dropped. Everything else comes across: nested blocks, flow style such as ports: [80, 443], block scalars written with | or >, quoted and unquoted strings, and multiple documents separated by ---, which come back as a JSON array. The result is minified on one line by design; the JSON formatter is there if you want it indented.

How to convert YAML to JSON

  1. Paste your YAML into the left box. The JSON appears on the right as you type.
  2. If something will not parse, the status line names the line number and what it expected.
  3. Switch to JSON to YAML to go the other way.
  4. Result to input feeds the output back in, which is a quick way to check a file round trips unchanged.
  5. Press Copy to take the result.

Common questions about YAML to JSON

My Compose file has secrets in it. Is pasting it safe?

No. The parser is JavaScript running on this page, so the file stays on your own device. Nothing is sent, logged or stored, which is the point: a Compose file or a pipeline definition often has secrets in it, and those should not be pasted into somebody else's server.

Why did my country code NO become false?

A YAML 1.1 parser reads the bare word no as the boolean false, which is why the country code for Norway turns into false. That is the Norway problem. This converter follows YAML 1.2, where only true and false are booleans and no, yes, on and off all stay strings, so it does not happen here. If your own parser still does it, quote the value as "NO".

What is not supported?

Anchors and aliases (&base and *base), merge keys (<<:), explicit tags such as !!str, and the explicit key form. Each of those is reported by name rather than quietly mishandled, because a converter that silently drops part of your config is worse than one that says it cannot. Expand them first and the rest converts.

What happens to my comments?

They are dropped, because JSON has no way to represent a comment. Nothing else is lost. Going the other way, from JSON to YAML, there are no comments to carry in the first place, so that direction round trips exactly.

Why does it complain about a tab?

YAML forbids tabs for indentation, and every parser rejects them, so a file that looks correctly aligned in your editor can fail everywhere. This is the single most common reason a hand-written YAML file will not load. Set your editor to insert spaces for .yml and .yaml files and the problem goes away for good.

Next

Related tools

All Dev tools