JSONToonPro
JSON converter tool

JSON to YAML Converter Online

Convert JSON objects, arrays, and configuration data to clean YAML instantly, or switch directions and convert YAML back to JSON. Choose indentation, quote strings when needed, sort keys for stable diffs, and download a ready to use YAML file. Everything runs locally in your browser.

100% client sideYAML to JSONCopy and download
Indent
34 nodes
Input/ JSON
420 chars25 lines
Output/ YAML
295 chars20 lines

YAML Is a Superset of JSON

Since YAML 1.2 the specification states that every valid JSON document is also a valid YAML document. Paste raw JSON into a YAML parser and it will accept it. That fact makes this conversion less of a translation and more of a reformatting: the data model on both sides is the same set of maps, sequences, and scalars, and only the syntax changes.

What you gain is readability and comments. What you gain in risk is whitespace sensitivity and a set of implicit typing rules that surprise people. The rest of this page is about both.

Side by Side Example

A deployment configuration, first as JSON and then as the block style YAML the converter produces.

JSON input

{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": { "name": "web", "replicas": 3 },
"spec": {
"containers": [
{ "name": "api",
"image": "ghcr.io/acme/api:1.4.0",
"ports": [8080, 9090] },
{ "name": "sidecar",
"image": "envoy:1.29",
"ports": [15000] }
],
"restart": "always"
}
}

YAML output

apiVersion: apps/v1
kind: Deployment
metadata:
name: web
replicas: 3
spec:
containers:
- name: api
image: ghcr.io/acme/api:1.4.0
ports:
- 8080
- 9090
- name: sidecar
image: envoy:1.29
ports:
- 15000
restart: always

Every brace, bracket, comma, and quotation mark is gone. The structure is now carried entirely by indentation and by the hyphen that marks a sequence item.

Indentation Rules

  • Two spaces per level is the near universal convention. The spec only requires consistency, but every linter and every example you will meet uses two.
  • Tab characters are forbidden as indentation. This is a hard rule in the specification, not a style preference, and a stray tab produces a parse error that often points at the wrong line.
  • A sequence under a mapping key may be indented or written flush with the key. Both are legal, which is why you will see two different looking styles in real repositories.
  • Sibling keys must line up in the same column exactly. A single extra space silently changes the meaning by nesting the key under its predecessor.

Configure your editor to show whitespace and to insert spaces rather than tabs before you edit YAML by hand. It removes an entire category of bug.

Block Style and Flow Style

YAML supports two ways of writing collections. Block style uses indentation and is the readable default. Flow style uses braces and brackets and looks exactly like JSON, which is why the superset claim holds.

Same value, both styles

# block style
ports:
- 8080
- 9090
 
# flow style
ports: [8080, 9090]

Flow style is useful for short lists where a vertical block would waste six lines to say very little. Mixing the two in one file is entirely legal and often produces the most readable result.

When Strings Need Quoting

YAML infers scalar types from the shape of the text, and unquoted values are resolved against a set of patterns. This is convenient right up until a value happens to match a pattern you did not intend.

Written asParsed asQuote it to get a string
noBoolean false in YAML 1.1Write "no"
yes / on / offBooleans in YAML 1.1Quote the value
1.20Float 1.2, trailing zero lostWrite "1.20" for a version
1.2.3String, three dots is not a numberSafe unquoted but quoting is clearer
0755Octal integer 493 in YAML 1.1Write "0755" for a permission code
12:30Sexagesimal number in YAML 1.1Write "12:30" for a time
null / ~ / (empty)NullWrite "null" for the literal word
@handleReserved indicator, parse errorMust be quoted
*refAlias referenceMust be quoted

The Norway problem

The best known example: a list of ISO country codes containing NO for Norway. Under YAML 1.1 rules, the unquoted token no is a boolean, so Norway silently becomes false and a country vanishes from the list. The same trap catches ON for Ontario and, in some parsers, the chemical formula shorthand and any field where a two letter code is legitimate data. Quote your codes.

Multi-line Strings, Comments, and Anchors

Three YAML features have no JSON equivalent at all, and they are the main reason teams prefer YAML for configuration.

Block scalars, comments, and anchors

# A comment. JSON has no way to write this.
 
script: | # literal, newlines preserved
set -euo pipefail
npm ci
npm run build
 
summary: > # folded, newlines become spaces
This long sentence is wrapped in the file
but arrives as a single line of text.
 
defaults: &defaults # anchor
retries: 3
timeout: 30
 
staging:
<<: *defaults # alias, merges the anchor
url: https://staging.example.com

The pipe indicator keeps line breaks, which is what you want for shell scripts and embedded code. The greater than indicator folds wrapped lines into one paragraph, which is what you want for prose. Anchors and aliases let you define a block once and reuse it, and the merge key pulls those values into another mapping.

Where YAML Is Used

ToolFileWhy YAML
KubernetesManifests and Helm valuesDeeply nested specs that humans edit and review
Docker Composecompose.yamlService definitions with shared blocks via anchors
GitHub Actions.github/workflows/*.ymlMulti-line run steps benefit from block scalars
AnsiblePlaybooks and inventoriesReadable task lists that double as documentation
OpenAPIopenapi.yamlLarge specs where comments explain intent
Static site generatorsFront matter and configTerse metadata at the top of content files

Config work rarely stops at one format. Browse the full converter collection for YAML to JSON when a tool demands strict JSON, JSON to XML for older enterprise pipelines, and JSON Schema to validate the configuration you just wrote.

How to convert JSON to YAML

Three steps, zero setup
01

Paste or upload JSON

Add a JSON object, array, or config payload into the input panel. Use the sample button to load realistic service config data.

02

Tune YAML formatting

Choose indentation, quote strings when needed, and sort keys for stable config diffs.

03

Copy or download YAML

The YAML output updates live as you type. Copy it into your config file or download a ready to use .yaml document.

Built for config-heavy work

Format JSON API payloads, deployment settings, and app config data into readable YAML without sending private values anywhere.

100% client side

Private configs stay in your browser. No upload pipeline, no server storage.

Live conversion

Convert JSON to YAML as you type with clear errors for invalid input.

Formatting controls

Switch indentation, quote strings, or sort keys for predictable output.

Nested data ready

Objects, arrays, booleans, numbers, nulls, and empty structures are preserved.

YAML to JSON

Reverse common YAML config data back into clean JSON with one click.

Config workflow

Copy YAML or download a ready to use file for config and deployment work.

Frequently asked questions

7 answers
Paste valid JSON into the input panel or upload a .json file. The YAML output is generated instantly in the right panel. You can choose 2-space or 4-space indentation, quote strings, sort keys, copy the result, or download a .yaml file.

YAML to JSON Converter

Need to convert YAML back to JSON? Use the YAML to JSON tab or click Swap. Paste any YAML config file including Kubernetes manifests, Docker Compose files, and GitHub Actions workflows and get clean JSON output instantly. The parser supports YAML mappings, lists, strings, numbers, booleans, and null values.

More JSON Tools