JSON and YAML are two notations for the same data
JSON wraps objects in braces { } and arrays in brackets [ ], and puts double quotes around keys and strings. YAML expresses the same structure with indentation and a leading hyphen (-) on list items, and leaves out most quotes. A JSON object becomes a YAML mapping and an array becomes a sequence. Numbers, booleans and null map across as well. The YAML 1.2 specification states that the main goal of that revision was to make YAML a strict superset of JSON, which is why most valid JSON documents can also be read as YAML as they are.
Both panes of this converter are editable. Edit the JSON pane and the YAML pane is rebuilt; edit the YAML pane and the JSON pane is rebuilt. The arrow in the middle shows which pane is currently the source. When you click a line or move with the arrow keys, the line with the same value lights up in the other pane, and the path line below shows the location, such as owner › name, along with the type of the value. That helps most in long YAML files where indentation alone makes it hard to tell which item a line belongs to.
| Data | JSON | YAML |
|---|---|---|
| Object / mapping | {"port": 8080} | port: 8080 |
| Array / sequence | {"tags": ["web", "api"]} | tags: |
| Nesting | {"db": {"host": "localhost"}} | db: |
| Number vs. number-like string | {"a": 8080, "b": "8080"} | a: 8080 |
| Boolean and empty value | {"on": true, "x": null} | "on": true |
| Multi-line string | {"memo": "first line\nsecond line"} | memo: |- |
| Empty object and empty array | {"a": {}, "b": []} | a: {} |
When you need to go between JSON and YAML
Configuration files that people edit tend to be YAML, while data that programs exchange tends to be JSON. So one task often involves both formats.
- Kubernetes manifests: the Kubernetes documentation recommends writing configuration files in YAML rather than JSON. Both work, but YAML is easier for people to read. You need a conversion when you turn a resource you pulled from a cluster as JSON into a YAML file, or when you pass a YAML manifest to an API or script that only accepts JSON.
- Docker Compose and GitHub Actions: both tools accept configuration only as YAML. If an example or an API response comes as JSON, you have to move it into YAML, and a missing quote can change the type of a value.
- Validating and comparing: to check a YAML configuration with a tool that takes JSON, such as a JSON Schema validator or jq, you first convert it to JSON. For a Compose file full of anchors and merge keys, the expanded JSON shows at a glance which values each service actually gets.
- Checking the traps before reading: even the same YAML changes meaning if the program reading it follows YAML 1.1: no becomes false and 0755 becomes 493. The reading check below lets you see whether your file has such values before you deploy it.
How to use it
- Paste into whichever pane holds what you have, JSON or YAML. If you open a .json, .yaml or .yml file with the Open file button or by dragging it in, it goes into the pane that matches the extension.
- The result appears in the other pane right away. If you edit the result pane, that pane becomes the source and the first pane is rebuilt.
- Select a line and the line with the same value lights up in the other pane; when the panes sit side by side, a connecting line is drawn between the two lines. Scrolling one pane scrolls the other to the same position.
- With the options above the panes, choose the indent (JSON: 2 spaces, 4 spaces or minified; YAML: 2 or 4 spaces), the YAML version to read with (1.2 or 1.1) and whether an array is split into several YAML documents.
- Use the buttons below the panes to copy or save as a file. If the file you opened was
app.yaml, the JSON is saved asapp.json.
Values that YAML 1.1 and 1.2 read differently
YAML decides the type of an unquoted value from its shape, and those rules differ between versions. The YAML 1.2 Core schema accepts only true and false (in a few letter-case variants) as booleans, and accepts only the 0o prefix for octal. The earlier YAML 1.1 type rules read yes, no, on, off, y and n as booleans, integers starting with 0 as octal, numbers joined by colons as base 60, and anything shaped like 2024-03-01 as a date. Conversely, the 1.1 float rule requires a decimal point, so 1e5 is a string in 1.1.
The catch is that many programs still read YAML the 1.1 way. Python's PyYAML describes itself as a complete YAML 1.1 parser. Go's yaml v3 mostly follows 1.2, but it still reads and writes octal as 0777, as 1.1 does, and accepts yes, no, on and off as booleans only when decoding into a boolean type. The Kubernetes documentation also says to use only true or false for boolean values, not yes, no, on or off, and to wrap values that look like booleans in quotes. The Docker Compose documentation likewise tells you to always write HOST:CONTAINER ports as quoted strings so they do not collide with YAML base 60.
| Unquoted value | YAML 1.2 Core | YAML 1.1 | JSON → YAML result |
|---|---|---|---|
true | boolean true | boolean true | "true" |
yes | string "yes" | boolean true | "yes" |
no | string "no" | boolean false | "no" |
on | string "on" | boolean true | "on" |
NO | string "NO" | boolean false | "NO" |
y | string "y" | boolean true | "y" |
~ | null | null | "~" |
0755 | number 755 | number 493 (octal) | "0755" |
0o17 | number 15 (octal) | string "0o17" | "0o17" |
12:30 | string "12:30" | number 750 (base 60) | "12:30" |
2222:22 | string "2222:22" | number 133342 (base 60) | "2222:22" |
8080:80 | string "8080:80" | string "8080:80" | 8080:80 |
1e5 | number 1e5 | string "1e5" | "1e5" |
1_000 | string "1_000" | number 1000 | "1_000" |
2024-03-01 | string "2024-03-01" | date | "2024-03-01" |
The last column shows how a value that was a string in JSON is written in YAML. If either version could read it as something other than a string, it is wrapped in double quotes. 8080:80 needs no quotes because the 80 after the colon exceeds a single base 60 digit (0 to 59), so both versions read it as a string, but a port such as 2222:22, where the second number is 59 or less, becomes a number in 1.1.
When the YAML pane is the source, the reading check below finds every value in the document that the two versions read differently and lists it with its line number. Click a chip to jump to that line. If you switch the reading version to 1.1, the JSON result is rebuilt with the 1.1 rules too, so you can preview the values a program such as PyYAML would actually receive.
What happens to YAML-only features
| YAML | JSON result |
|---|---|
Comment # … | Not carried over. The status line shows how many |
Anchor &base and alias *base | The anchor's value is expanded where the alias appears |
Merge key <<: *base | The imported keys are merged into that mapping. A key written directly in the mapping keeps its own value |
Multiple documents --- | An array with one item per document |
Block string |, > | A string containing the line breaks as \n (> joins lines with a space) |
Custom tag such as !Ref | The tag is dropped and only the value is kept. Shown in the reading check |
Numeric key 1: a | String key "1" |
Mapping with [ ] or { } as a key | Error. JSON keys can only be strings |
.inf, .nan | Error. JSON numbers have no infinity or NaN |
When converting JSON to YAML, key order is kept exactly as entered. The browser's built-in JSON parser moves integer-like keys such as "2024" to the front of an object, so this converter reads JSON with its own order-preserving parser. Strings that contain line breaks are written as a | block, and empty objects and arrays are written as {} and [].
Numbers are copied exactly as written
The JSON specification (RFC 8259) explains that implementations can exchange numbers reliably when they do not expect more precision than IEEE 754 binary64 doubles. Browsers handle numbers that way too, so an ordinary converter turns 9007199254740993 into 9007199254740992 and 4.50 into 4.5. This converter does not calculate with numbers; it copies the digits as written, so neither change happens. Only notations that JSON does not have, such as 0o17 or 0x1F on the YAML side, are turned into the same value in decimal.
There is one exception. The JSON number 1e5 is a number in YAML 1.2, but in YAML 1.1 it has no decimal point and is a string. So when converting JSON to YAML, exponent notation is written with a decimal point and a sign, as in 1.0e+5. Both versions read that as the number 100000. A rewritten number is flagged in the reading check.
Common mistakes
- Tabs for indentation: the YAML specification forbids tab characters in indentation because systems treat tabs differently. Replace tabs with spaces in your editor.
- No space after the colon:
port:8080is a single string, not a key. A key and its value need a space after the colon, as inport: 8080. - The same key twice: the YAML specification requires mapping keys to be unique, and the JSON specification warns that the behavior of a program receiving an object with repeated names is unpredictable. This converter reports a repeated key as an error either way. The YAML keys
1:and"1":collide as well, because they are the same key in JSON. - Loose JSON syntax: a comma after the last item, single quotes, unquoted keys and
//comments are not standard JSON. If your configuration is written as JSON5 or JSONC, fix these before pasting it in. - on: in GitHub Actions: the
on:key of a workflow is the string "on" in YAML 1.2, but a 1.1-style parser reads it as the boolean true. That is why the key seems to vanish when you read a workflow file with a Python script and edit it. - Time-like and port-like values:
18:30and2222:22become base 60 numbers in 1.1. It is safer to quote times and ports.
Limits and cautions
- Input up to 5 MB (5,242,880 bytes) and results up to 10 MB are converted. It opens UTF-8 files (with or without a BOM) and UTF-16 files with a BOM.
- YAML comments, quoting style and blank lines are not preserved when the YAML is rebuilt. If you use YAML as the source and then edit the JSON pane, the YAML is written anew, so a YAML that had comments can be restored once with Undo in the status line.
- Custom tags such as CloudFormation's
!Refare dropped and only the value is kept. They are not converted into the{"Ref": …}form that CloudFormation uses in JSON. - If aliases expand to an excessive amount of data (an alias that points to a group of aliases, and so on), the conversion stops to prevent resource exhaustion.
- The YAML 1.1 reading follows the 1.1 type rules on yaml.org. Some edge cases differ from real 1.1-style programs. For example, y and n are booleans under those rules but PyYAML reads them as strings. The JSON → YAML result wraps all such values in quotes, so they stay strings whichever way they are read.
- The conversion handles syntax only. Whether the key names and value types match what Kubernetes or Compose require is something to check with each tool's own validation command.
Sources
- 01YAML — YAML Ain't Markup Language version 1.2.2§1.2 main goal is to be a strict superset of JSON, §3.2.1.1 mapping keys are unique, §6.1 no tabs in indentation, §10.3.2 Core schema (null, bool, int and float resolution table) — checked 2026-10-20
- 02YAML 1.1 types — Boolean, Integer, Floating-Point, Timestamp, Merge Keybool (y, yes, on and so on), int (octal 0…, base 60), float (decimal point required, exponent needs a sign), timestamp, merge (<<) rules — together with type/int.html, float.html, timestamp.html and merge.html
- 03IETF — RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format§4 names SHOULD be unique and behavior with repeated names is unpredictable, §6 binary64 precision and interoperability, §8.1 UTF-8
- 04Kubernetes — Configuration OverviewWrite configuration in YAML rather than JSON, use only true and false for booleans, avoid yes, no, on and off, quote values that look like booleans
- 05Docker Docs — Compose file reference: services (ports)Always write HOST:CONTAINER as a quoted string so it does not collide with YAML base 60
- 06Docker Docs — FragmentsCompose files that use anchors (&), aliases (*) and the YAML merge type (<<)
- 07go-yaml v3 READMEMostly supports YAML 1.2, 1.1 booleans only when decoding into a boolean type, octal as 0777 like 1.1
- 08PyPI — PyYAML"complete YAML 1.1 parser"
- 09yaml (JavaScript) documentationThe parser this converter uses (2.9.1, ISC). Alias expansion limit; merge keys are a 1.1 feature not in the 1.2 specification
- 10GitHub Docs — Workflow syntax for GitHub ActionsWorkflow files use YAML syntax, with the extension .yml or .yaml
Frequently asked questions
Why do some values get quotes when I convert JSON to YAML?
Values such as "no", "on", "0012", "18:30" and "2024-03-01" would be read by YAML as booleans, numbers or dates instead of strings if they had no quotes, so they are wrapped in double quotes. This keeps a value that was a string in JSON a string in YAML; the value itself does not change.
What is the difference between YAML 1.1 and 1.2?
They use different rules to decide the type of an unquoted value. In the 1.2 Core schema the only booleans are true and false, so yes, no, on and off are strings. YAML 1.1 also reads yes, no, on, off, y and n as booleans, 0755 as octal 493, 12:30 as base 60 750 and 2024-03-01 as a date. PyYAML is a YAML 1.1 parser.
Are YAML comments carried over to JSON?
No. JSON has no comment syntax. The status line shows how many comments were left out, and if you were using YAML as the source and edited the JSON pane, so that the YAML was rebuilt, the Undo button brings back the original YAML.
What happens to anchors (&) and merge keys (<<)?
An alias (*) is expanded to the value its anchor points to, and a merge key merges the keys of the imported mapping into that place. If the same key already exists, the value written directly in that mapping is kept. JSON has no reference syntax, so the same value is repeated everywhere it is used.
What happens to several documents separated by ---?
With two or more documents you get a JSON array with one item per document. In the other direction, turn on the 'Array = documents (---)' switch to write each item of a top-level JSON array as its own document in the YAML pane.
Do large numbers and values like 4.50 stay as they are?
Numbers are copied exactly as written, so a large integer such as 9007199254740993 and the trailing zero of 4.50 do not change. Exponent notation such as 1e5 is written as 1.0e+5 so that YAML 1.1 also reads it as a number. If the program that reads the result converts numbers to doubles, that program may round a large integer.
Where do I fix an error?
The path line shows the pane with the error, the line and column, and the reason, and the line number is highlighted. Common causes are tabs used for indentation, a missing space after a colon, and a trailing comma, single quotes or a comment in JSON. If you pasted YAML into the JSON pane, a 'Move to YAML pane' button appears.
Is my configuration file sent to a server?
No. The conversion happens only in your browser, and your input and files are not sent to a server. Nothing is kept in the address bar or in browser storage either, so even a configuration containing passwords or tokens stays on this screen.