JSON to YAML Converter

Convert JSON to readable YAML, with quotes added only where a value would otherwise change meaning: yes, 1.0, 12:30 and dates included.

Enable JavaScript to customise; default output below.

Nothing is uploaded. The conversion happens in this tab.

Indent

Two spaces is what most YAML in the wild uses. Tabs are not valid YAML indentation.

More options Show
Live preview data.yaml
name: my-plugin
version: "1.0"
active: true
tags:
  - wordpress
  - yaml
deploy:
  branch: main
  at: "12:30"

Output is valid and updates as you type.

Paste JSON, get YAML that reads back as the same data. The quoting is the part that matters, and it is done for you.

How to use

  1. Paste the JSON. Invalid JSON is reported with a line and column before anything is converted.
  2. Pick the indent. Two spaces is the convention; YAML forbids tabs for indentation, so they are not offered.
  3. Leave multiline strings as blocks unless you need a single line. A literal block shows the text as text instead of escaping the newlines.
  4. Add the document marker if the file will hold more than one document, or if your tool insists on it.
  5. Copy the YAML. Every value that would change meaning unquoted has been quoted, and nothing else has.

Example

{
  "name": "my-plugin",
  "version": "1.0",
  "active": true,
  "tags": ["wordpress", "yaml"],
  "deploy": { "branch": "main", "at": "12:30" }
}

becomes

name: my-plugin
version: "1.0"
active: true
tags:
  - wordpress
  - yaml
deploy:
  branch: main
  at: "12:30"

version and at are quoted and name is not. Bare 1.0 is a number, and bare 12:30 is 750 to a YAML 1.1 reader, which is the sort of thing that only shows up in production.

Pitfalls

  • yes, no, on, off, y and n are booleans to a YAML 1.1 reader, and most readers still are. A country code of NO unquoted becomes false.
  • A date-looking string becomes a date object in many parsers, so 2026-09-26 is quoted here to keep it a string.
  • Times are base 60. 12:30 reads as 750 unless quoted, and 1:2:3 as 3723.
  • Leading zeros disappear when a value is read as a number, which is why 007 is quoted.
  • Tabs are not valid YAML indentation anywhere. If you reindent the output by hand, use spaces.
  • A key can need quoting too. A key of yes is boolean true, and a key containing a colon is ambiguous to most readers.
  • YAML is a superset of JSON, so the reverse direction needs no conversion at all: a YAML parser reads JSON as it stands.
  • Anchors, aliases and comments have no JSON equivalent, so nothing here emits them. Add them by hand afterwards if you want them.

Compatibility

The output targets YAML 1.2 and stays readable by YAML 1.1 parsers, which is what the extra quoting is for. Block scalars, flow collections for empty containers and double-quoted escapes are all core YAML, supported by PyYAML, js-yaml, Symfony YAML and Go’s gopkg.in/yaml. The tool itself runs in any browser from 2017 onwards, with no upload.

Frequently asked questions

Why are some strings quoted and others not?
Only the ones that would be read as a boolean, a number, a date, a time or something structural. Everything else is left bare so the file stays readable.
Can I convert YAML to JSON here?
Not in this tool. YAML has features JSON cannot hold, so that direction needs choices about what to drop.
Is the key order kept?
Yes, the order of the JSON object is the order of the YAML mapping.
What happens to an empty object or array?
It is written inline as {} or [], which is valid YAML and unambiguous.
Does it support multiple documents?
One in, one out. Turn on the document marker and concatenate the results if you need several in a file.
Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.