JSON to YAML

Paste JSON and get clean YAML you can drop into a config file. Values that YAML could misread, like yes, on or 1.10, are quoted so nothing changes meaning.

  • 100% free
  • Runs in your browser
  • No uploads
Indent

How to convert JSON to YAML

  1. Paste or open the JSON. It converts as you type. If the JSON has a mistake, you'll see the line and column instead.
  2. Pick the indent. Two spaces is the usual choice for Kubernetes and Compose files; some teams use four.
  3. Copy or download the YAML. Download saves a .yaml file named after the file you opened.

Example: a Kubernetes deployment

Tools often produce Kubernetes manifests as JSON. Converted, the deployment below reads like the YAML you'd write by hand. Note the label canary: 'no' and the value '1.10': both keep their quotes, because unquoted no is false to some YAML readers and 1.10 would become the number 1.1.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
    canary: 'no'
spec:
  replicas: 2
  template:
    spec:
      containers:
        - name: web
          image: nginx:1.27
          ports:
            - containerPort: 80
          env:
            - name: VERSION
              value: '1.10'

JSON and YAML side by side

In JSONIn YAML
{"name": "web"}name: web
"ports": [80, 443]ports: then - 80 and - 443 on their own lines
nullnull (YAML also accepts ~)
"a\nb"A block starting with |-
"yes"'yes' (quoted on purpose)
{} and []{} and []

Tips for YAML config files

  • YAML uses spaces for indentation, never tabs. Keep the indent the same throughout a file.
  • Version numbers, postcodes and IDs with leading zeros should stay quoted strings in YAML, as they are here.
  • To check YAML you've edited by hand, paste it into the YAML to JSON converter: it reports the line of any mistake.

Frequently asked questions

Why are some strings in quotes and others not?

YAML reads unquoted text as numbers, booleans or null when it can. Without quotes, the string "yes" or "on" can turn into true in older YAML readers, "1.0" into the number 1 and "null" into nothing. The converter quotes exactly those strings so the YAML means the same as your JSON. Tick Quote every string if a tool you use expects all strings quoted.

Is the YAML valid for Kubernetes and Docker Compose?

Yes. The output is standard YAML 1.2 using block style (one key per line, lists with dashes), which Kubernetes, Docker Compose, GitHub Actions, Ansible and most other tools read. Check the key names your tool expects; the converter doesn't change them.

How are multi-line strings written?

A string with line breaks becomes a literal block (|), so each line appears as written rather than as \n escapes. With Wrap long text on, long single-line strings are folded over several lines at about 80 characters; YAML joins them back into one line when read.

Can I get comments into the YAML?

No, because JSON has no comments to carry over. Add them to the YAML afterwards with # at the start of a line.

Does key order change?

No. Keys stay in the order they are in the JSON, and numbers keep their value: a 20-digit ID is written out in full instead of being rounded.