JSON to YAML Converter
Runs locallyTurn JSON into clean YAML for Kubernetes, Compose or CI config — strings that YAML would misread are quoted.
JSON
YAML
apiVersion: apps/v1kind: Deploymentmetadata:name: apilabels:app: apitier: backendspec:replicas: 3template:spec:containers:- name: apiimage: ghcr.io/example/api:1.4.2ports:- containerPort: 8080env:- name: FEATURE_FLAGvalue: 'on'- name: COUNTRYvalue: 'NO' YAML is a superset of JSON — the risk is in the unquoted strings
Every JSON document is already valid YAML 1.2, so the conversion is about style: YAML drops the braces, brackets and most quotes and uses indentation instead, which is why Kubernetes manifests, Docker Compose files and CI pipelines are written in it. The data model is the same — maps, lists, strings, numbers, booleans and null — so nothing is lost going from JSON to YAML.
What can go wrong is a string that YAML reads as another type once its quotes are gone. 3.10 becomes the number 3.1, a port mapping such as 22:22 is a base-60 number (1342) to YAML 1.1 parsers, and on, off, yes and no — including the country code NO — are booleans to PyYAML, SnakeYAML (Spring) and go-yaml v2, which also reads y and n that way. This converter quotes any string that would change meaning, so the YAML parses to the same values in both YAML 1.1 and 1.2 tools. Choose single or double quotes everywhere if your style guide asks for it.
Indentation is two spaces by default, the convention for Kubernetes and Compose; list items are indented under their key. Paste the result into the YAML formatter to lint it, or run it back through the YAML to JSON converter to confirm the round trip.
JSON
{"version":"3.10","country":"NO","enabled":true,"ports":["80:80"],"cmd":"echo \"hi\"","empty":""}YAML
version: '3.10' country: 'NO' enabled: true ports: - '80:80' cmd: echo "hi" empty: ''
Unquoted, version would load as 3.1 and country as false in YAML 1.1 parsers. enabled is a real boolean, so it stays unquoted.
Where people get caught
The Norway problem
NO, no, on and off are booleans to YAML 1.1 parsers. The converter quotes them; if you edit the YAML by hand later, keep the quotes.
Version numbers that lose a digit
python: 3.10 loads as 3.1. Any version string that looks like a number stays quoted in the output.
Tabs in YAML
YAML forbids tabs for indentation. The output always uses spaces; an editor that converts them to tabs will break the file.
Key order in sorted output
Sorting keys helps reviews, but some tools read the first key specially — Kubernetes does not, while some CI systems show jobs in file order. Leave sorting off when order carries meaning.
About JSON to YAML conversion
How it works in 4 steps · 4 common use cases · 4 questions answered
About JSON to YAML conversion
How it works in 4 steps · 4 common use cases · 4 questions answered
How it works
- 1.Paste or drop JSON; the YAML updates as you type.
- 2.Pick 2 or 4 spaces and how strings are quoted.
- 3.Sort keys if you want a stable order for reviews.
- 4.Copy the YAML or download it as a .yaml file.
Common use cases
- •Writing a Kubernetes manifest from a JSON API response
- •Converting a package.json-style config to YAML
- •Moving CI or Compose settings from JSON to YAML
- •Making a long JSON config easier to review
FAQ
Is every JSON file valid YAML?
Yes, for YAML 1.2. Converting still helps because block-style YAML is easier to read and edit, and it is what most config tools expect.
Why are some strings quoted in the output?
They would change type without quotes — "on" or "NO" would become booleans and "3.10" the number 3.1 in common YAML parsers. Quoting keeps the value a string.
Can I get double quotes everywhere?
Yes. Set Strings to Always "double" or Always 'single'. Numbers, booleans and null are never quoted.
Does it keep large numbers exactly?
The JSON is parsed with a standard parser, so integers above 9007199254740991 are rounded. Send such IDs as strings to keep every digit.