JSON to YAML

Convert JSON to YAML format

About JSON to YAML

JSON to YAML rewrites pasted JSON as YAML, the format of Kubernetes, Docker Compose, and GitHub Actions files. Objects become indented mappings and arrays become lists of - items, at any depth; empty objects and arrays are written {} and []. Numbers are copied exactly as in the JSON, so 1.10 and a 20-digit ID are not changed. A string that a YAML reader could take for something else, such as yes, no, 123, a date, or text containing a colon followed by a space, is put in single quotes. Long lines are never folded, and the work happens in your browser with js-yaml.

Example

A small JSON configuration and the YAML the tool returns (note the quoted version, yes, and colon strings):

JSON

{
  "name": "api",
  "version": "1.10",
  "debug": false,
  "id": 12345678901234567890,
  "answer": "yes",
  "ports": [80, 443],
  "note": "Time: 10:30"
}

YAML

name: api
version: '1.10'
debug: false
id: 12345678901234567890
answer: 'yes'
ports:
  - 80
  - 443
note: 'Time: 10:30'

How to convert JSON to YAML

  1. 1Paste JSON into "JSON input".
  2. 2Click "Convert"; invalid JSON shows the parse error from your browser instead.
  3. 3Read the YAML in "YAML output".
  4. 4Click "Copy", or "Download" to get the same YAML as data.yaml.

Formats and limits

Input
JSON text
Output
YAML in block style, two-space indentation, file data.yaml
Key order
as in the JSON, keys such as 10 included

Where your file is processed

js-yaml converts your JSON inside the browser tab, and the pasted text is not uploaded; the YAML exists only on this page until you copy or download it. An error, such as a JSON parse error, is reported to us as text with quoted fragments replaced, together with the tool name and your browser version.

Frequently asked questions

Will yes, no, or on be read as booleans?

No. The tool quotes such strings, writing 'yes', 'no', 'on', 'off', and 'y', so readers that follow the older YAML 1.1 rules also keep them as text. Real JSON booleans are written true and false.

Do numbers keep their exact digits?

Yes. A number is written with the exact digits of your JSON: 1.10 stays 1.10 and 12345678901234567890 keeps all its digits. A version stored as a JSON string is quoted in the YAML, so it stays text.

Can I convert the YAML back to JSON?

Yes, with YAML to JSON. Its reader turns decimals into JSON numbers, so an unquoted 1.10 comes back as 1.1, but the quoted strings this tool writes come back unchanged.