Developer tool

JSON to YAML Converter

Select a direction, paste a configuration and get a copyable or downloadable conversion.

Runs in your browser. No upload.

YAML comments and formatting are not preserved when converting to JSON.

About this tool

JSON to YAML Converter made simple.

Convert JSON objects and arrays to readable YAML or parse YAML into formatted JSON. The converter uses a safe JSON-compatible YAML schema and limits aliases. YAML comments, anchors and original formatting cannot be preserved in JSON output; everything is processed in this browser.

Guide

Using JSON to YAML Converter

The JSON to YAML Converter turns JSON text into readable YAML, or reads YAML and shows it as indented JSON. You choose a direction, paste up to 500,000 characters, press Convert, then copy the result or download it as a file. It suits configuration files and small data sets. It cannot keep YAML comments, anchors or the original layout when the output is JSON.

How to use it

  1. Pick JSON to YAML or YAML to JSON with the two buttons above the boxes. Switching direction empties the output box but keeps the text you typed in the input box.
  2. Paste your text into the input box. It cannot be empty and it can be at most 500,000 characters long, otherwise the tool shows a message instead of converting.
  3. Press Convert. The converted text fills the output box. If the text is not valid, a message points you to brackets, commas, quotes or indentation.
  4. Press Copy result, or Download result to save converted.yaml or converted.json. Clear empties both boxes.

Worked examples

JSON to YAML

You enter
Direction
JSON to YAML
Text
{"name":"UsefulVerse","fast":true,"tags":["a","b"],"nested":{"n":1.5,"empty":[],"none":null}}
You get
Yaml
name: UsefulVerse fast: true tags: - a - b nested: n: 1.5 empty: [] none: null

Objects become indented keys and lists become dash items. Order is kept as written. Empty lists show as [] and null stays null.

Run through the tool’s own code.

Comments and anchors do not survive

You enter
Direction
YAML to JSON
Text
# server settings base: &b port: 80 copy: *b
You get
Json
{ "base": { "port": 80 }, "copy": { "port": 80 } }

The comment line is dropped. The anchor &b and its alias *b are replaced by two full copies of the same data, because JSON has no way to point back to an earlier value.

Run through the tool’s own code.

Plain words stay text

You enter
Direction
YAML to JSON
Text
date: 2001-12-14 flag: yes empty: n: ~ hex: 0x1F
You get
Json
{ "date": "2001-12-14", "flag": "yes", "empty": null, "n": null, "hex": 31 }

The converter reads YAML with a JSON-compatible set of rules. A date stays a string and the word yes stays a string. An empty value and ~ become null, and 0x1F is read as the number 31.

Run through the tool’s own code.

Two documents in one file

You enter
Direction
YAML to JSON
Text
a: 1 --- b: 2
You get
Message
Invalid JSON or YAML. Check indentation, quotes and data types.

The line of three dashes starts a second YAML document. The converter expects a single document and refuses the text. Convert each document on its own.

Run through the tool’s own code.

When it helps

  • Turn a JSON settings file into YAML for a tool that reads YAML, such as a build or deployment file.
  • Turn YAML into JSON to feed it to a script, an API or a test that expects JSON.
  • Check how a small YAML snippet is understood by looking at the JSON it becomes.
  • Make a long JSON example easier to read in documentation by showing it as YAML.

Limits to keep in mind

  • Input must not be empty and can have at most 500,000 characters. YAML with more than one document, or with a tag the JSON-compatible rules do not know, is refused.
  • Going to JSON drops YAML comments, expands anchors and aliases into copies and ignores formatting. The YAML and the JSON are the same data and no longer the same text.
  • In the YAML output, a string such as yes or on is written without quotes. Some older YAML tools treat those words as true or false, so add quotes by hand when the file is read by such a tool.
  • The error messages are general. They tell you whether the text looks like a JSON or a YAML problem, but not the line or character where it went wrong.

Tips

  • Convert there and back once, and compare the result with your start. Differences show what the conversion changed.
  • Keep your comments in the original YAML file. Use the converter for copies, not as the only place the file lives.
  • Quote version numbers like 1.10 in your JSON as strings. The converter then keeps them as text and does not turn them into the number 1.1.

Sources

Common questions

About JSON to YAML Converter.

How do I convert JSON to YAML?

Choose JSON to YAML, paste valid JSON into the input box and press Convert. The YAML appears in the output box. Press Copy result to copy it, or Download result to save it as converted.yaml.

Are YAML comments kept when I convert to JSON?

No. JSON has no comments, so they are removed. Anchors and aliases are also replaced by full copies of the data, and the original line breaks and spacing are not kept. Keep the YAML file if you need those.

Is my text uploaded to a server?

No. The conversion happens in your browser. The first time you convert, the page loads a small parsing library from this site, but the text you paste stays on your device and is not sent anywhere.

Why did my number or date change type?

YAML guesses types from plain text. With the rules used here, 0x1F becomes the number 31 while a date such as 2001-12-14 stays a string. If a value must stay text, put it in quotes in the YAML.

Why does the converter say my YAML is invalid?

Common causes are tabs used for indentation, a missing space after a colon, an unclosed bracket, or several documents separated by three dashes. Fix the indentation and quotes, then try again.

Can I convert a JSON file with a very large number?

The converter reads JSON the way a browser does. Whole numbers that are too large to be held exactly may be rounded in the output. Put such identifiers in quotes in the JSON so they stay exact.

Does YAML to JSON keep the order of keys?

Yes. Keys are written in the order they appear in the YAML text, and the JSON output is indented by two spaces. The tool does not sort keys in either direction.

Are YAML comments preserved when converting to JSON?

No. Comments, aliases and formatting are not represented in JSON output. The converter uses a safe schema and limits YAML aliases.