JSON to YAML converter
JSON to YAML converter
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?
Paste your JSON into the source and the corresponding YAML appears next to it. Use Download to save the YAML file.
Yes, under the YAML 1.2 specification: a JSON document is also valid YAML. Older YAML 1.1 readers differ, so this page quotes strings they could misread.
YAML permits comments and uses less punctuation, which can suit hand-edited configuration. JSON has stricter syntax and no comments; either format can represent the same data.
Yes. Those files are handled as ordinary JSON, preserving key order and number digits. Objects become YAML mappings; the converter does not write short tags such as !Ref.
Mostly for configuration that people edit by hand. The YAML written here keeps in mind the readers such files meet: PyYAML, go-yaml and older Kubernetes tooling, which read YAML 1.1.
It follows the Settings ⚙ indent. YAML cannot be indented with tabs, so a tab setting writes 2 spaces. A string containing line breaks becomes a literal block.
Yes. Press ⇄ to make the YAML your source and read it back into JSON. Values, key order and the original number text survive the round trip.
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.
No. Producing YAML from your JSON happens entirely in this browser tab. The document is neither uploaded nor logged, and conversion still works offline once loaded.