فارسی

Convert YAML to JSON (and Back)

Convert YAML to JSON and back. Nested maps, lists, and non-English text survive the trip, and a syntax error points at the line that caused it.

Use this tool in your browser without installing software.

About this tool

Configuration files are usually YAML — Docker Compose, GitHub Actions, Kubernetes and many apps — while APIs and code expect JSON. This page goes both ways: it reads YAML and writes tidy JSON, or turns JSON back into YAML. Nested maps, lists, block strings and non-English text keep their shape. A few things are worth knowing up front: YAML comments have no place in JSON and are dropped; anchors and aliases are expanded to the value they point at; timestamps become standard ISO strings; and .nan or .inf become null with a warning because JSON has no such values. Multi-document files (separated by ---) come out as an array of documents. Nothing is uploaded and your text never leaves the browser.

How to use it

  1. 1

    Paste YAML or JSON into the input box, or open a file. The direction comes from the file extension and can be changed with the buttons above.

  2. 2

    The result appears as you type. On a syntax error, the line, column and technical reason show under the box so you can find the spot.

  3. 3

    Copy the result or download the file. To go back, press “Reverse” and the result becomes the new input.

If the file will not open

  • YAML fails even though the structure looks right.

    Replace invisible tabs with spaces and keep each nesting level consistent; two spaces is the usual choice. Put special characters such as : and # inside quotes when they are part of a string.

  • A phone number or postcode lost its leading zero in the JSON.

    Put that value in quotes in the YAML, like "09123456789", so it is read as text instead of a number. The same goes for anything that starts with a zero: 0912 unquoted becomes the number 912.

  • The YAML output is full of quotes and hard to read.

    Quotes appear only where the value would otherwise change meaning, for example a key such as n or a string that looks like a date. That is correct YAML. If you are reading it yourself, the original file is the more readable copy.

Frequently asked questions

Where did the YAML comments go?

JSON has no place for notes between values, so comments are dropped during conversion. If those notes matter, keep the original YAML file or put the explanation inside a real key such as description.

Why do some values look different in the JSON?

YAML infers types from unquoted values: 20 is a number, true is a boolean and 2026-11-24 can be read as a date. Dates become ISO strings in the JSON output. Quote any YAML value that must remain text.

What does “unexpected end of the stream” mean?

A structure was left open: a bracket or brace is not closed, or a list stops in the wrong place. The line and column under the message show where. Another common cause is using tabs for indentation; YAML only accepts spaces.

My file has several documents (---). What comes out?

Multiple YAML documents separated by --- become a JSON array in the same order. A single document produces its own value. In reverse, a JSON array becomes one YAML document containing a list, not a stream of separate documents.

Is my file or text stored anywhere?

Conversion runs in your browser. The input contents are not sent to the server. The YAML library is loaded from this site.