Skip to content
TextBench Lab

JSON to YAML Converter

Turn JSON into clean, readable YAML for config files, Kubernetes, Docker Compose or CI pipelines. Values like yes, no, on and 0755 are quoted, so their meaning never changes. It runs in your browser, so nothing is uploaded.

Up to 1,000,000 characters (about 1 MB). JSON Lines become separate YAML documents.

Indent
Keys
0
Depth
0
Lines
0

How to convert JSON to YAML

  1. Paste your JSON

    Paste an object, an array or JSON Lines, up to 1,000,000 characters. The YAML appears as you type.

  2. Fix any error

    If the JSON is invalid, the line and column of the problem are shown with a plain reason.

  3. Choose the format

    Pick 2 or 4 spaces of indentation, and sort the keys A to Z if you want a stable order.

  4. Copy or download

    Copy the YAML, or download it as a .yaml file ready for your project.

Features

  • Safe quoting

    Text that YAML would read as a boolean, null or number, such as yes, off, null or 1e3, stays text.

  • Readable multiline text

    Strings with line breaks become block literals, so scripts and certificates stay easy to read.

  • Exact numbers

    Every number is written exactly as in your JSON, even IDs longer than JavaScript can hold.

  • Private

    The conversion runs in your browser. Your data is never uploaded or stored.

What this tool does

JSON and YAML describe the same kinds of data: objects, lists, text, numbers, true, false and null. JSON is strict and easy for programs to exchange, while YAML is easier for people to read and edit, which is why Kubernetes manifests, Docker Compose files and CI workflows use it. This converter writes your JSON as clean YAML, and every value keeps its type and meaning.

Paste your JSON and the YAML appears while you type. Copy it or download it as a .yaml file.

Why quoting matters in YAML

YAML lets you write most text without quotes, and that is part of why it reads so well. The catch is that a parser decides the type of an unquoted value by looking at it. A plain true is a boolean, null is nothing, and 42 is a number. Older YAML 1.1 parsers go further: they also read yes, no, on, off, y and n as booleans, 0755 as an octal number, and 12:30 as a number in base 60.

This is the well-known "Norway problem". A list of country codes that contains NO turns into false for Norway when it is written without quotes, and a file mode of 0755 becomes the number 493.

This tool quotes every string that any common YAML version could read as something else, so the text in your JSON stays text:

  • Words that look like booleans or null: yes, no, on, off, y, n, true, false, null and ~, in any letter case.
  • Anything that starts like a number: 1e3, 0755, 0x1F, 1_000, 2026-10-22, .5, .inf.
  • Strings that start with a character that has a special meaning in YAML, such as -, ?, :, #, &, *, !, |, >, %, @ or a quote.
  • Strings that contain ": " or " #", end with a colon, or start or end with a space.
  • The empty string, written as ''.

Everything else stays plain, so names, sentences, URLs and paths stay readable. When a string needs quotes but no escapes, single quotes are used. When it holds a control character, a byte order mark or a lone surrogate, it gets double quotes with escapes such as \u0001, so nothing invisible slips into your file.

Multiline strings as block literals

A JSON string with line breaks, such as a shell script, an SQL query or a certificate, becomes a block literal. It starts with a | on the key line, and every line of the text follows on its own indented line, exactly as it is. The indicator after the | tells the parser how the text ends: | keeps one final line break, |- means there is none, and |+ keeps several. Quotes and # need no escaping inside it.

A block literal cannot hold every text exactly. If the first line starts with a space, or the text has carriage returns or control characters, the string is double-quoted with \n escapes instead, so the data still reads back identically.

Numbers, empty values and nested data

Numbers are written exactly as they appear in your JSON, so an ID like 12345678901234567890 is not rounded and 1.0 stays 1.0. A note warns you when a number is too long for some YAML tools to read exactly. Empty arrays and objects are written as [] and {}, and null stays null.

Nested objects become indented blocks, and arrays become lists with a dash per item. An array of objects, the most common shape in config files, puts the first key on the dash line and the other keys below it:

env:
  - name: MODE
    value: production

Indentation and sorted keys

Two spaces is the most common style and keeps deep files narrow; four spaces makes levels easier to tell apart. List items always start with a dash and one space, and the lines of an item line up after the dash. Both read back to the same data.

Sort keys A to Z orders the keys inside every object, at every level, by character code, so uppercase letters come before lowercase ones. Arrays keep their order, because the order of a list has meaning. This helps when you keep config in version control.

JSON Lines and errors

JSON Lines files hold one JSON value per line. When the tool finds several values, each one becomes its own YAML document, and the documents are separated by --- lines.

JSON allows the same key twice in one object, but YAML does not. If your JSON repeats a key, a warning names the key and its line, and the YAML keeps the last value, just like JSON.parse in JavaScript.

If the JSON is not valid, the tool shows the line and column of the first problem with a plain reason, such as a trailing comma or single quotes. The JSON formatter helps you tidy and check the input, and the guides on common JSON errors and on what an Unexpected token error means explain the usual fixes.

To turn the same JSON into a spreadsheet instead, use the JSON to CSV converter. Config values are sometimes stored as Base64, and the Base64 encoder and decoder reads them. To learn when to keep JSON compact and when to make it readable, see format or minify JSON.

Privacy

The conversion runs in your browser. Your JSON is not uploaded, saved or tracked, and there is no sign-up. The input is limited to 1,000,000 characters, about 1 MB, so the page stays fast. Like every page on this site, this one may show ads from third-party vendors once ads are switched on, and those vendors can use cookies. Read the privacy policy for details.

Frequently asked questions

Why are some values put in quotes?

YAML reads some plain words as other types. Older YAML parsers turn yes, no, on and off into booleans, and 0755 into an octal number. Quotes keep those values as text, exactly as they were in the JSON.

How are strings with line breaks written?

As block literals that start with | or |-. Each line of the text gets its own line in the YAML, so a shell script or a certificate stays readable. The ending tells the parser whether the text ends with a line break.

Can I convert JSON Lines?

Yes. When each line holds its own JSON value, every value becomes a separate YAML document, and the documents are separated by --- lines.

Does sorting keys change my data?

No. Only the order of keys inside each object changes, at every level. Arrays keep their order, because the order of items in a list has meaning.

Is the YAML valid for Kubernetes and Docker Compose?

The output is standard YAML that any YAML 1.2 parser reads back to the same data, and it is quoted so that older YAML 1.1 parsers agree. Whether the content is a valid manifest depends on your keys and values.

Is my JSON uploaded?

No. Everything happens in your browser and nothing is sent or saved. The JSON is limited to 1,000,000 characters, about 1 MB, so the page stays fast.