json

FormatValidateConvert

JSON to YAML converter

Source

JSON

Result· read-only

—YAML

The result appears here.

Start over?

This clears the source, the result and the Path.

Convert

JSON to YAML converter.

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.

1.1

readers get the same values back: PyYAML, go-yaml v2

0

values, keys or number texts changed on the round trip

0

bytes leave your machine

Written for 1.1 readers too

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.

1

The JSON

{
  "country": "no",
  "enabled": true,
  "version": "012",
  "released": "2001-12-14"
}
2

The YAML it gives, at the default settings

country: "no"
enabled: true
version: "012"
released: "2001-12-14"

Options and notices

1

A top-level array of two services

[
  { "name": "web" },
  { "name": "api" }
]
2

The YAML with One YAML document per array element on

---
name: web
---
name: api

Notice

One document per element

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

Exponent numbers

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

Lone surrogates

A string holding a lone surrogate is written, with a notice that other YAML readers may reject it.

Lossless on data

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.

1

The first example’s YAML, read back with ⇄

country: "no"
enabled: true
version: "012"
released: "2001-12-14"
2

The JSON it gives: the one it was written from, byte for byte.

{
  "country": "no",
  "enabled": true,
  "version": "012",
  "released": "2001-12-14"
}

Private by construction

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?

FAQ

Frequently asked questions

Didn’t find your answer?Write to us on the contact page →
How do I convert JSON to YAML?

Paste your JSON into the source and the corresponding YAML appears next to it. Use Download to save the YAML file.

Is JSON valid YAML?

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.

Why use YAML instead of JSON?

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.

Can I convert a CloudFormation, Swagger or OpenAPI file to YAML?

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.

What is YAML used for?

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.

How is the YAML indented?

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.

Can I convert the YAML back to JSON?

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.

Why are some of my strings quoted?

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.

Does the key order change?

No. Keys are written in the order the JSON has them.

My JSON has an error. What happens?

Nothing is written. The status bar gives the line and column of the first error, and the source marks it.

Is my JSON uploaded?

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.

Keyboard shortcuts

Send feedback

Questions, bug reports and feature requests are all welcome. A bug report is easiest to act on with the shape of the document that caused it — never send anything confidential.

Email us

Contact page, in a new tab, so this page stays as it is.

Settings

Indent

The result is written with it — YAML and XML at 2 spaces when it is Tab.

Code text size
14 px

Both panes.

Wrap long lines

Load from a URL

Your browser fetches it directly — the request goes to that site, never to us.