JSON to YAML Converter

Convert JSON to YAML instantly: paste JSON and this free JSON to YAML converter writes clean, readable YAML with 2-space indentation, ready for Kubernetes manifests, Docker Compose, GitHub Actions and other config files.

⇄ YAML to JSON
Paste JSON, upload a file or press Sample. It converts as you type.

Private by design: the conversion runs in your browser and nothing is uploaded or saved. Only your option choices are remembered on this device.

Key order is kept. The YAML has no comments or anchors (JSON has none to carry over); strings like yes, no, 1.10 and 007 are quoted so they stay strings.

How to convert JSON to YAML

  1. Paste JSON into the left box, drop a .json file on it, or press Upload. If the JSON has an error, the status line shows the line and column; format and validate the JSON first if it needs more cleaning up.
  2. The YAML appears as you type. Choose 2 or 4 spaces, and whether to quote all strings.
  3. Copy it into your config, or Download .yaml.

JSON to YAML example

A service definition in JSON:

{
  "name": "checkout",
  "image": "shop/checkout:2.4.1",
  "replicas": 2,
  "env": { "LOG_LEVEL": "info", "CACHE": true },
  "ports": [8080, 9090]
}

converts to this YAML. Braces and quotes disappear, nesting is shown by indentation, and array items start with a dash:

name: checkout
image: shop/checkout:2.4.1
replicas: 2
env:
  LOG_LEVEL: info
  CACHE: true
ports:
  - 8080
  - 9090

Why some strings are quoted

YAML guesses types from how a value looks, and older YAML 1.1 parsers (still used by many tools) guess more than you might expect. The converter quotes any string that could be misread, so the YAML means exactly what the JSON meant:

{
  "country": "NO",
  "enabled": "yes",
  "version": "1.10",
  "zip": "02134",
  "released": "2026-09-25",
  "empty": "",
  "motd": "Welcome!\nMaintenance on Sunday."
}
country: 'NO'
enabled: 'yes'
version: '1.10'
zip: '02134'
released: '2026-09-25'
empty: ''
motd: |-
  Welcome!
  Maintenance on Sunday.
  • 'NO' and 'yes': unquoted, YAML 1.1 reads them as false and true (the "Norway problem").
  • '1.10': unquoted, it becomes the number 1.1, so a version string would change.
  • '02134' and '2026-09-25': unquoted, some parsers read an octal number or a date.
  • The multi-line message becomes a |- block, which keeps the line break and drops the final newline, like the original string.

Kubernetes and multi-document YAML

Kubernetes, Helm and many CI tools accept several YAML documents in one file, separated by ---. Put the resources in a JSON array and tick Top-level array → separate documents:

---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  ports:
    - port: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 2

Without that option, a top-level array becomes a single YAML list.

What changes between JSON and YAML

  • Nothing is lost. Strings, numbers, true/false, null, objects and arrays all have a direct YAML form, and key order is kept.
  • Empty objects and arrays are written as {} and [].
  • Comments can be added afterwards; JSON has none to carry over.
  • Unicode is written as is, not escaped.

To go back, the YAML to JSON converter turns YAML (including comments, anchors and multiple documents) into JSON. To look through a large JSON file before converting, open it in the JSON viewer.

Convert JSON to YAML on the command line

  • yq (mikefarah): yq -p json -o yaml input.json > output.yaml
  • Python (PyYAML): python -c 'import sys, json, yaml; print(yaml.safe_dump(json.load(sys.stdin), sort_keys=False))' < input.json. Without sort_keys=False, PyYAML sorts the keys alphabetically.

Frequently asked questions

How do I convert JSON to YAML?

Paste the JSON into the left box or upload a .json file. The YAML appears on the right as you type, indented with 2 spaces. Press Copy, or Download .yaml to save it as a file.

Why are some values in quotes in the YAML?

Because without quotes, YAML would read them as a different type. Older YAML 1.1 parsers read yes, no, on, off and NO as booleans, 1.10 as the number 1.1 and 02134 as a number, so strings that look like that are quoted to stay strings everywhere. Plain words and numbers are left unquoted.

Is YAML a superset of JSON?

Practically yes: YAML 1.2 was designed so that valid JSON is also valid YAML. That is why converting JSON to YAML never loses data, only JSON syntax such as braces, brackets and quotes.

Does converting JSON to YAML change the key order?

No. Keys are written in the same order as in the JSON, and array items keep their order.

How do I convert JSON to Kubernetes YAML with several resources?

Put the resources in a JSON array and tick "Top-level array → separate documents". Each item is written as its own YAML document starting with ---, which kubectl apply -f reads as separate resources.

Can I add comments to the YAML?

Yes, after converting. JSON has no comments, so the output has none either, but you can add lines starting with # anywhere in the YAML file.

What happens to long strings and multi-line text?

Long strings stay on one line (they are never folded), and strings with line breaks are written as literal block scalars (|-), which keep every line break exactly.

Is my JSON sent to a server?

No. The conversion runs in your browser with the js-yaml library, and nothing you paste or upload is sent anywhere or stored. Only option choices such as the indent are remembered on your device.

This converter is provided as is. Review generated YAML before you deploy it, and test config changes somewhere safe first. Spotted a wrong result? Tell us. Last reviewed .