JSON to YAML converter
The result appears here.
Convert
Your document never leaves the browser.
JSON to YAML that PyYAML and Kubernetes read back correctly — in your browser.
Paste JSON and get YAML that means the same thing to whatever reads it next, including the older YAML 1.1 parsers most tooling still uses.
The page reads YAML as 1.2, but the YAML it writes lands in PyYAML, go-yaml v2 and older Kubernetes tooling, which read 1.1. So any string either version would read as something else is quoted: yes, no, on, off, y and n in every case; ~ and null; number-like text such as 012, 1_000, 1:20 and 0b101; dates like 2001-12-14; .inf and .nan; and anything starting with a YAML indicator or carrying leading or trailing spaces.
A string with line breaks is written as a literal block (|) with the right chomping indicator, so it reads back exactly.
The JSON
{
"country": "no",
"enabled": true,
"version": "012",
"released": "2001-12-14"
}The YAML it gives, at the default settings
country: "no"
enabled: true
version: "012"
released: "2001-12-14"A top-level array of two services
[
{ "name": "web" },
{ "name": "api" }
]The YAML with One YAML document per array element on
---
name: web
---
name: apiNotice
One YAML document per array element: a top-level array becomes a stream of documents separated by ---. A one-element array written that way reads back as its element, and the result says so.
Notice
Numbers in exponent form, like 1e5, are kept as written; YAML 1.1 readers such as PyYAML read them as strings, and the result warns you.
Notice
A string holding a lone surrogate is written, with a notice that other YAML readers may reject it.
JSON to YAML and back gives the same values, the same key order and the same number text. Indentation follows Settings ⚙; YAML cannot indent with tabs, so a tab setting writes 2 spaces.
Press ⇄ to read the YAML back on the same page: it becomes the source, and the JSON it gives is the result, so you can check the round trip before you commit the file.
The first example’s YAML, read back with ⇄
country: "no"
enabled: true
version: "012"
released: "2001-12-14"The JSON it gives: the one it was written from, byte for byte.
{
"country": "no",
"enabled": true,
"version": "012",
"released": "2001-12-14"
}The conversion runs in your browser, in the same engine the editor uses. The document is never uploaded, never logged and never leaves your machine — there is no server to send it to. Once the page has loaded it keeps working with the connection off.
Going the other way?
Because unquoted they would change type in some reader. "no" unquoted is false to YAML 1.1, and "012" is the number 10. Quoting keeps them strings everywhere.
No. Keys are written in the order the JSON has them.
Nothing is written. The status bar gives the line and column of the first error, and the source marks it.