To convert JSON to YAML, write each object as indented key: value lines and each array as - items, and keep numbers, true, false and null as they are. The part that goes wrong is strings: YAML guesses a type from unquoted text, so NO, yes, 1.10, 0755 and 2026-11-17 need quotes, or a parser may read them as false, true, 1.1, 493 or a date. The JSON to YAML Converter adds those quotes, reads its own output back to check that nothing changed, and turns YAML into JSON as well, all in your browser.
How to convert JSON to YAML with Zutilium
- Open the JSON to YAML Converter and keep JSON → YAML selected under Direction. The page starts with a Kubernetes Deployment as an example.
- Paste your JSON over it in the JSON input box, select Open file, or drop a .json file on the panel. Files and pasted text can be up to 10 MiB.
- Under YAML output, choose Indentation (2 spaces or 4 spaces) and Lists under a key: Indented, or Level with the key (kubectl) to match the way kubectl prints lists.
- Tick Quote every string value if you want every string in quotes, and Start with --- if the YAML will be joined with other documents in one file.
- Read the status line and the notes under the boxes, then select Copy YAML or Download .yaml.
The YAML updates as you type. A clean result's status line includes "Checked: it reads back as the same data in YAML 1.2 and YAML 1.1 parsers." That means the output was parsed back both ways and compared with your JSON, value by value. The check covers JSON of up to 600,000 values; larger files are written by the same rules, and the page says they were not checked.
The notes flag anything to review, such as a repeated key like $.spec.replicas, where the last value is kept, as JSON.parse does. JSON with a comment or a trailing comma stops with its line and column instead, for example "JSON error at line 2, column 3: Invalid JSON token. JSON does not allow comments." The guide to fixing invalid JSON covers each error, and the JSON Formatter & Validator finds them one at a time.
Nothing is uploaded: the conversion runs in a background worker in your browser, and only your option choices are saved, in local storage. The output box shows the first 5,000 lines of a long result, while Copy and Download include everything.
JSON to YAML syntax mapping
YAML 1.2 was designed as a strict superset of JSON, according to the YAML 1.2.2 specification, so both formats hold the same data. YAML replaces most of the punctuation with indentation:
| JSON | YAML | Rule |
|---|---|---|
{"name": "web"} |
name: web |
Objects become key: value lines |
{"a": {"b": 1}} |
a:, then b: 1 indented |
Nesting is indentation, spaces only |
["a", "b"] |
- a, then - b |
Arrays become - items |
{} and [] |
{} and [] |
Empty ones keep their brackets |
"web" |
web |
Quotes only where needed |
3, true, null |
3, true, null |
Unchanged |
"a\nb" |
A literal block | Line breaks stay line breaks |
Worked example: a Kubernetes ConfigMap
Here is a ConfigMap as JSON, with every value a string:
{
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": { "name": "app-settings" },
"data": {
"FEATURE_CACHE": "on",
"COUNTRY": "NO",
"APP_VERSION": "1.10",
"UMASK": "0022",
"RELEASE_DATE": "2026-11-17",
"MAX_RETRIES": "3",
"LOG_LEVEL": "info"
}
}
The converter writes this YAML and reports "6 strings are quoted so YAML keeps them as text":
apiVersion: v1
kind: ConfigMap
metadata:
name: app-settings
data:
FEATURE_CACHE: "on"
COUNTRY: "NO"
APP_VERSION: "1.10"
UMASK: "0022"
RELEASE_DATE: "2026-11-17"
MAX_RETRIES: "3"
LOG_LEVEL: info
Without those quotes, PyYAML would load true, false, 1.1, 18, a date object and the number 3; only info would stay text. ConfigMap data is meant to hold strings, so Kubernetes would also refuse the unquoted file.
The YAML Norway problem and other values that change type
The Norway problem is the best-known case: the list [NO, SE, DK] comes back from PyYAML as [False, 'SE', 'DK'], because the YAML 1.1 boolean type counts y, n, yes, no, on, off and their capitalized forms (PyYAML skips y and n). YAML 1.2, published in 2009, dropped those words and other risky implicit types, but PyYAML (and with it Ansible), Ruby's YAML library and Kubernetes still read the old way. One file can mean different things to different programs:
| Unquoted value | YAML 1.2 core schema | PyYAML (YAML 1.1) |
|---|---|---|
NO, no, off |
Text | false |
yes, on |
Text | true |
y, n |
Text | Text |
1.10 |
Number 1.1 | Number 1.1 |
0755 |
Number 755 | Number 493 (octal) |
0o755 |
Number 493 | Text |
22:22 |
Text | Number 1342 (base 60) |
2026-11-17 |
Text | Date |
1e3 |
Number 1000 | Text |
1_000 |
Text | Number 1000 |
~, null or nothing |
null |
null |
Other readers add their own twists. Kubernetes reads yes, no, on, off and octal like PyYAML, but it also reads y as true, keeps 22:22 as text and reads 1e3 as a number. Ruby's Psych turns 22:22 into 80,520, and its YAML.safe_load stops at an unquoted date with "Tried to load unspecified class: Date". Even ruamel.yaml, which defaults to YAML 1.2, returns a date for 2026-11-17.
That is why quoting for one YAML version is not enough. The JavaScript yaml package, for example, writes country: NO and port: 22:22 without quotes by default, which is correct YAML 1.2; with version: '1.1' it quotes those but leaves 0o755 bare, which YAML 1.2 reads as 493. Zutilium's converter quotes any string that either version could read as another type, keys included, so "on": and "200": come out quoted.
When a YAML string needs quotes
| The string | Examples | Unquoted, a parser |
|---|---|---|
| Is a boolean or null word | NO, on, null, ~ |
Reads false, true or null |
| Looks like a number | 1.10, 0755, 1e3, 22:22 |
Reads a number |
| Looks like a date | 2026-11-17 |
Reads a date |
| Starts with a reserved character | *.example.com, @team, !important |
Fails, or reads a tag |
Contains : or # |
key: value, x #y |
Fails, or cuts at the # |
| Starts or ends with a space, or is empty | " padded ", "" |
Trims it, or reads null |
Quoting a string that doesn't need it never changes it, with one catch: inside double quotes a backslash starts an escape, so "C:\temp" contains a tab and "^\d+$" is an error. Put Windows paths and regular expressions in single quotes ('C:\temp') or double each backslash. The converter picks single quotes for such strings.
Kubernetes, Docker Compose and GitHub Actions configs
The Kubernetes configuration good practices say to use only true or false and to quote anything that looks like a boolean, such as "yes". Fields like an environment variable's value take strings only, and Kubernetes turns YAML into JSON before the API server checks types, so an unquoted value: 03788745 fails with an error such as json: cannot unmarshal number into Go struct field EnvVar.spec.template.spec.containers.env.value of type string. Maintainers closed that report as working as intended, so the fix is to quote the value.
If your JSON came from kubectl get -o json, ask kubectl for -o yaml instead. Since Kubernetes 1.35, kubectl get -o kyaml also prints KYAML, a YAML style that always quotes value strings. Quote every string value gives the same protection in ordinary block YAML.
Docker Compose's port reference says to always quote HOST:CONTAINER mappings to avoid YAML base-60 numbers: PyYAML reads 49100:22 as 2,946,022, while 8080:80 survives only because 80 is above 59. Compose also asks for quotes around true, false, yes and no in environment.
In GitHub Actions, an unquoted matrix such as [3.10, 3.12] hands setup-python the number 3.1, so the job looks for Python 3.1 and fails. The on: key is the other trap: PyYAML loads it as the boolean True, which trips up scripts that read workflow files, so the converter writes "on":, which GitHub reads exactly like on:. GitHub's workflow syntax also requires quotes around filter patterns that start with *, [ or !. Here is a workflow converted from JSON with the default options:
name: CI
"on":
push:
branches:
- main
paths:
- "**.py"
- requirements.txt
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
- "3.12"
- "3.14"
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- run: |
pip install -r requirements.txt
pytest
Five strings are quoted: the on key, the **.py pattern and the three versions. The multi-line run script became a literal block (|), which keeps every line as written.
Comments: YAML has them, JSON does not
JSON has no comment syntax, which is a common reason to move a config to YAML. In YAML, # starts a comment at the beginning of a line or after a space, so url: https://example.com/a#b keeps its fragment while note: a #b loses everything from the space on. The converter quotes values like that. JSON has no comments to carry over, so add yours after converting:
# Feature flags, read once at startup
data:
FEATURE_CACHE: "on" # must stay a string
The reverse trip drops every comment, and the notes say how many were dropped. Keep the YAML as the file people edit and generate JSON from it when a program needs JSON, or keep notes in a field such as "_comment" that your program ignores.
YAML to JSON: anchors, merge keys and several documents
Select YAML → JSON under Direction and the YAML result becomes the new input, so you can check a round trip. Opening a .yaml or .yml file switches direction for you. Under JSON output, choose Indentation (2 spaces, 4 spaces or Minified) and Read YAML as: YAML 1.2 (current standard) or YAML 1.1 (PyYAML, Ansible). In 1.2 mode, the notes point out values a YAML 1.1 reader would see differently, such as "Line 7: NO is text in YAML 1.2 but false in YAML 1.1."
JSON has no references, comments, dates or tags, so a few things change on the way:
- Aliases such as
*defaultsare expanded into full copies, and<<merge keys are applied while Apply << merge keys is ticked, which is the default. Keys written in the mapping win over merged ones. - Documents separated by
---become a JSON array, or you pick one under Documents, where Kubernetes documents are labeled by kind and name, such as "Document 2 · Deployment web". - Dates,
.infand.nanstay as text, a custom tag such as!Refis dropped with its value kept, and a repeated key is an error that names its line.
This CI excerpt uses an anchor and a merge key:
.defaults: &defaults
image: python:3.12
retry: 2
lint:
<<: *defaults
retry: 0
script: [ruff check .]
With Minified selected, it becomes:
{".defaults":{"image":"python:3.12","retry":2},"lint":{"image":"python:3.12","retry":0,"script":["ruff check ."]}}
Other ways to convert JSON to YAML
On the command line, yq (the Go version) converts with yq -Poy config.json > config.yaml and goes back with yq -o json config.yaml. In Python, PyYAML does it in one line:
python3 -c 'import sys, json, yaml; print(yaml.safe_dump(json.load(sys.stdin), sort_keys=False, allow_unicode=True), end="")' < config.json > config.yaml
Without sort_keys=False, PyYAML sorts keys alphabetically, and without allow_unicode=True it escapes letters such as ü. It quotes NO, yes and 1.10 but leaves y and 1e3 bare, which Kubernetes reads as true and YAML 1.2 parsers read as 1000. In JavaScript, the yaml package's YAML.stringify(data, { version: '1.1' }) quotes the YAML 1.1 lookalikes, but JSON.parse has already rounded a number such as 12345678901234567890 to 12345678901234567000.
Whichever method you use, test the result: read it back with YAML → JSON in YAML 1.1 mode, then compare the original and the round-tripped JSON in JSON Diff, which ignores key order and formatting. The guide to comparing two JSON files explains how to read the differences.
Troubleshooting
A value changed type after someone edited the YAML
Hand edits often drop quotes. Convert the file to JSON with Read YAML as set to the version your program uses, look for true, false or numbers where you expect text, and quote those values again.
"Tabs are not allowed for indentation in YAML"
YAML indents with spaces only. Replace the leading tabs with spaces, which most editors can do for a whole file, and convert again.
"Duplicate key" errors
Keys must be unique within a mapping, so the error names the key and its line. A second << in the same mapping counts as a repeat: merge both sources in one key, as in <<: [*a, *b].
!Ref and other tags disappear from the JSON
JSON has no tags, so the converter keeps the value and adds a note with the line. For AWS CloudFormation, rewrite short forms in full first: !Ref MyBucket becomes Ref: MyBucket, which converts to {"Ref": "MyBucket"}, the form CloudFormation expects in JSON.
The file is too large
Input can be up to 10 MiB, and YAML with more than about 800,000 values in one document (fewer in long ones) or 1.5 million in total is refused so the browser tab doesn't run out of memory. Split it into smaller files or documents.
Frequently asked questions
Is JSON valid YAML?
Almost always. YAML 1.2 was designed as a strict superset of JSON, so a YAML 1.2 parser reads ordinary JSON as it is. The exceptions are edge cases: YAML requires unique keys, and some parsers, such as PyYAML, reject JSON indented with tabs.
How do I convert YAML to JSON?
Select YAML → JSON in the JSON to YAML Converter, or open a .yaml file, then copy or download the JSON. Comments are dropped, aliases and merge keys are expanded, and several documents become an array. Choose YAML 1.1 under Read YAML as if the file is meant for PyYAML or Ansible.
What is the YAML Norway problem?
YAML 1.1 parsers read the unquoted country code NO as the boolean false, along with yes, no, on, off and their capitalized forms. YAML 1.2 fixed this, but PyYAML, Ruby and Kubernetes still apply the old rule, so write country: "NO".
Why does YAML turn 1.10 into 1.1?
Without quotes, 1.10 is a decimal number in every YAML version, and 1.10 equals 1.1. Quote version strings, as in python-version: "3.10".
Should I quote every string in YAML?
It isn't required, but it removes the guesswork, and Kubernetes' KYAML output does exactly that. Tick Quote every string value for that style; keys stay unquoted unless they need quotes.