Output will appear here
Output will appear here
Paste JSON and this tool writes the same data as block-style YAML: nested objects become indented mappings and arrays become - lists. A string is left unquoted only if it is plain words; anything a YAML parser could read as a number, boolean, null, date or syntax ("8080", "1.0", "no", "#fff") is double-quoted. The result loads back to exactly the input JSON.
By Ankit Aglawe · Updated · Runs entirely in your browser
Look at the two env values. Kubernetes env values must be strings, and both "false" and "no" are quoted in the output, so they stay strings instead of turning into booleans. nginx:1.27 is quoted too: it would load fine bare, but the converter only leaves plain words unquoted rather than guess.
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": { "name": "web", "labels": { "app": "web" } },
"spec": {
"replicas": 3,
"template": {
"spec": {
"containers": [
{
"name": "web",
"image": "nginx:1.27",
"env": [
{ "name": "DEBUG", "value": "false" },
{ "name": "REGION", "value": "no" }
]
}
]
}
}
}
}apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
replicas: 3
template:
spec:
containers:
- name: web
image: "nginx:1.27"
env:
- name: DEBUG
value: "false"
- name: REGION
value: "no""off" is quoted because YAML 1.1 parsers read a bare off as false. #0af is quoted because a bare # starts a comment. null stays null, the real boolean stays bare, and the empty array becomes [].
{
"logLevel": "off",
"timeoutSeconds": 2.5,
"retries": 3,
"debug": false,
"sentryDsn": null,
"theme": { "accent": "#0af", "font": "Inter" },
"allowedOrigins": ["https://app.example.com", "http://localhost:5173"],
"featureFlags": []
}logLevel: "off"
timeoutSeconds: 2.5
retries: 3
debug: false
sentryDsn: null
theme:
accent: "#0af"
font: Inter
allowedOrigins:
- "https://app.example.com"
- "http://localhost:5173"
featureFlags: []YAML 1.1 parsers such as PyYAML treat bare yes, no, on, off, y and n as booleans (the "Norway problem": country code NO becomes false). Those words, plus true, false, null and ~, are quoted in any letter case, so they stay strings.
Version numbers, ports, zip codes and dates ("1.0", "8080", "02134", "2024-01-15") are quoted. Left bare, 1.0 loads as a float, 02134 can load as an octal number and a date loads as a date object in PyYAML.
Any string that starts with something other than a letter or underscore, or contains characters outside letters, digits, spaces and _-./, is written as a JSON-style double-quoted string. That covers : , #, &anchor, *ref, !tag, @user and %. JSON string escapes are valid YAML, so nothing is lost.
A string with line breaks becomes a literal block (|-, or | when it ends with a newline), so it stays readable. If the text has tabs, leading spaces or trailing spaces on a line, it is written as a quoted string with \n escapes instead, because block scalars cannot carry those exactly.
Keys follow the same rule as values: user_name stays bare, while user name:, 2fa or on are double-quoted. Key order follows the JSON input.
An empty string becomes "", an empty array [] and an empty object {}, so none of them turn into null. An array inside an array is written - - 1, which every YAML parser reads as a list of lists.
Numbers are written the way JavaScript prints them after JSON.parse, so 1.0 comes out as 1 and integers above 2^53 lose precision. If a value must stay exact, keep it a string in the JSON and it will be quoted.
| JSON | YAML output | Notes |
|---|---|---|
{"a": 1} | a: 1 | Block mapping, two-space indent |
[1, 2] | - 1 / - 2 | One dash item per line |
"no", "on", "true" | "no", "on", "true" | Quoted so parsers keep them as strings |
"a: b", "#fff" | "a: b", "#fff" | Quoted to avoid mapping/comment syntax |
"8080", "1.0" | "8080", "1.0" | Quoted so they stay strings |
"a\nb" | |- block | Literal block for multi-line text |
null | null | |
"" | "" | |
[] / {} | [] / {} | Flow style for empties |
"user-name": 1 | "user-name": 1 | Non-identifier keys quoted |
Enter a JSON object or array in the left editor. The converter handles nested objects, arrays, and all JSON primitive types.
The right pane instantly shows the equivalent YAML with clean indentation, proper quoting, and multiline string handling.
Copy the YAML to your clipboard or download it as a .yaml file for use in Kubernetes manifests, Docker Compose, CI configs, or any YAML-based workflow.
Paste the JSON into the left pane and the YAML appears on the right. Copy it or download it as a .yaml file.
Mostly. YAML 1.2 was designed as a superset of JSON, so most YAML parsers can read JSON directly. Converting gives you the block style people expect in config files, and you can add comments afterwards.
Older YAML 1.1 parsers, including PyYAML and many tools built on it, read a bare no as false. Quoting keeps it a string in every parser.
Yes. The converter is tested by loading its output with js-yaml and comparing it to the input, including strings like "8080", "~", "&anchor", multi-line text, nested arrays and empty objects.
Yes, the output is plain block YAML. Keep env values and version numbers as strings in your JSON so they are emitted as strings.
No. JSON has no comments or references, so the output is one document with no anchors and no leading ---.
No. The conversion is plain JavaScript running on the page.
Need several formats at once? Convert All shows every output from one paste. Or browse all JSON converters.