Skip to content
cliplimeClipLime

Convert JSON to YAML

Paste JSON or drop a file and get clean YAML, with the values that older readers misread safely quoted.

Runs on your device, nothing is uploaded

Convert from

to

Paste, type, drop a file here or load one.

0 characters, 0 lines

Options

Indentation

At a glance

Input
JSON text or a .json file. A problem such as a trailing comma or single quotes is shown with its line and column.
Layout
Block style: one key per line, lists with a dash, and 2 or 4 spaces of indentation. Nothing is folded, so long text stays on one line.
Quoting
Text that a YAML reader could take for another type is put in quotes, such as "no", "1.10", "1,000", "2001-12-14" and "null". Everything else stays plain.
Several lines
A string with line breaks is written as a block with |- or |, so it stays readable. Text that starts with a space or a line break, or holds characters YAML cannot show, is written in double quotes with escapes.
Types
Numbers, true, false and null keep their types. Empty lists and objects are written as [] and {}.
Not added
JSON has no comments, and the converter never uses anchors, so the YAML has neither. Add comments by hand afterwards.
Privacy
Your JSON is converted in your browser tab and never uploaded.

How to do it

  1. 1

    Add your JSON

    Paste it, drop a .json file on the input box, or press Load a file. Example fills in a small list of people with nested values.

  2. 2

    Pick the indentation

    Under Options, choose 2 or 4 spaces. YAML does not allow tabs for indentation, so there is no tab choice.

  3. 3

    Check the YAML

    The result appears as you type. Look at the values in quotes: they are the ones a YAML reader might otherwise misread.

  4. 4

    Copy or download

    Press Copy, or Download to save a .yaml file.

Why people convert JSON to YAML

YAML is easier to read and edit by hand: no braces, no quotes around most keys, and comments are allowed. That is why Kubernetes, Docker Compose and GitHub Actions use it for configuration. Converting a JSON export or API response gives you a starting point to edit and annotate.

YAML 1.2 was designed so that almost any JSON file is also valid YAML, so a YAML parser can often read your JSON as it is. The conversion is for people, not for parsers. The price of the friendlier look is that indentation carries meaning, so one misplaced space changes the data.

How values are written

  • Plain text is left unquoted: name: Ana Silva, city: Lisbon, zip: 1000-001.
  • Numbers, booleans and null keep their types: age: 31, active: true, zip: null.
  • Text that looks like another type is quoted: country: "no", version: "1.10", joined: "2001-12-14", id: "007", price: "1,000".
  • Keys get the same care: "on": 1 and "2022": 1 are quoted, so they are not read as a boolean and a number.
  • A list uses a dash for each item, a list inside a list is written - - 1, and an empty list or object is [] or {}.
  • A string with line breaks becomes a block: notes: |- followed by the lines, indented.

Why the quotes matter

Older YAML 1.1 readers, which many tools still use, treat the unquoted words yes, no, on and off as booleans, and read values such as 014, 12:30:45 or 1,000 as numbers (1,5 becomes 15). The classic trap is the country code NO for Norway, which comes out as false. A quoted value is text in every YAML version, so the converter quotes anything that an older reader could take for something else. Readers that follow YAML 1.2 give the same result either way.

The quotes are a safe default, not a style choice. If you know your tool follows YAML 1.2 you can remove them by hand.

What to check afterwards

  • Repeated keys. If the JSON has the same key twice in one object, only the last value is kept, as JSON readers do.
  • Long numbers. Whole numbers with more than 15 digits can be rounded when the JSON is read, and a note warns you. Put such IDs in quotes in the JSON.
  • Very large and very small numbers. A number such as 1e-7 or 1e21 is written with a point in front of the exponent (1.0e-7, 1.0e+21), because older readers take 1e-7 for text.
  • Repeated data. Anchors and aliases are never written, so data that repeats is repeated in full. You can add anchors by hand.
  • What the target accepts. The output is standard YAML. Field names and required keys are the business of the tool that reads it, and this page does not check them.

Questions people ask

Why are some strings in quotes and others not?

Text that an older YAML 1.1 reader could take for a boolean, a number, a date or null is quoted, for example "no", "007", "2001-12-14" and "null". Everything else is written plain. A quoted value is text in every version of YAML.

Can I use tabs or other indentation?

You can choose 2 or 4 spaces. YAML does not allow tabs for indentation, and a minified single line is not offered for YAML because block style is the point of the format.

Will my comments be kept?

JSON has no comments, so there are none to keep. A file with // or / / comments is not valid JSON and is reported as an error with its line and column. Add comments to the YAML by hand after converting.

Is the result valid for Kubernetes or Docker Compose?

It is standard YAML. Whether a tool accepts the content depends on its own rules, such as field names and required keys. This page converts the format and does not check the content.

How are long text values and line breaks written?

Long text stays on one line and is never folded. A string that contains line breaks is written as a block, with |- when it has no final line break and | when it does. Text that starts with a space, a tab or a line break is written in double quotes with \n escapes instead, so no reader can mistake the leading whitespace for indentation. The file always ends with a line break, which a block of text needs to keep its own last line break.

Is my JSON uploaded?

No. The JSON is read and converted in your browser tab, so private data stays on your device.