ToolNimba Browse

🔁 JSON to YAML Converter

By ToolNimba Engineering Team · Updated 2026-06-19

YAML result
 

Paste valid JSON above, then choose Convert to YAML.

This JSON to YAML converter turns a block of JSON into clean, readable YAML right in your browser. Paste your JSON, choose an indent width, and you get properly indented YAML with nested objects as maps, arrays as dash lists, and strings quoted only when they actually need it. Nothing is uploaded, the conversion happens entirely on your device.

What is the JSON to YAML?

JSON (JavaScript Object Notation) and YAML (YAML Ain't Markup Language) describe the same shape of data: objects (maps of keys to values), arrays (ordered lists), and scalars (strings, numbers, booleans, null). They differ in syntax. JSON leans on braces, brackets, quotes, and commas, which makes it precise and easy for machines but noisy for humans. YAML drops most of that punctuation and uses indentation to show structure, which is why it has become the default for configuration files in tools like Docker Compose, Kubernetes, GitHub Actions, and Ansible.

Converting from JSON to YAML is mostly a matter of re-formatting. An object becomes a set of "key: value" lines, one per key, each indented under its parent. An array becomes a list of lines that each start with a dash and a space. A nested object or array simply moves to the next indentation level. Because YAML is a strict superset of JSON, every valid JSON document has at least one valid YAML representation, so the conversion never loses information.

The one part that needs care is quoting. In YAML a bare string like London needs no quotes, but a value such as true, 42, or yes would be read back as a boolean or a number rather than text, and a value containing a colon followed by a space (like Yes: maybe) would be mistaken for a nested key. This converter applies those rules for you: it leaves plain strings unquoted for readability and wraps only the values that would otherwise be misread, using double quotes with correct escaping. The result is YAML that is both tidy and safe to round-trip back to the same data.

When to use it

  • Turning a JSON API response or config snippet into YAML for a Docker Compose, Kubernetes, or GitHub Actions file.
  • Converting a settings object exported as JSON into the YAML format your tool or framework expects.
  • Making a dense JSON payload easier to read and review by reformatting it as indented YAML.
  • Migrating configuration from a JSON-based system to a YAML-based one without retyping it by hand.

How to use the JSON to YAML

  1. Paste or type your JSON into the input box (the Load sample button fills in an example).
  2. Pick the indent width, 2 spaces is the common default for YAML, 4 spaces is also supported.
  3. Click Convert to YAML to generate the result below.
  4. Check the YAML output, then use Copy to put it on your clipboard. Invalid JSON shows a clear error message.

Formula & method

Object → one "key: value" line per key, indented under its parent. Array → one "- item" line per element. Nested object or array → moves one indent level deeper. Strings are quoted only when a bare value would be misread as a number, boolean, null, or key.

Worked examples

A flat JSON object with a string, a number, and a boolean.

  1. Input: {"name": "Ada", "age": 36, "admin": true}
  2. Each key becomes its own line at indent level 0.
  3. The string "Ada" is safe as a plain scalar, so it stays unquoted.
  4. The number 36 and boolean true are written bare.

Result: name: Ada age: 36 admin: true

A JSON object containing an array and a nested object.

  1. Input: {"skills": ["math", "code"], "address": {"city": "London"}}
  2. The skills key has no inline value, so its array moves to the next indent level.
  3. Each array element becomes a dash line: "- math" and "- code".
  4. The address object also moves one level deeper as "city: London".

Result: skills: - math - code address: city: London

A value that must be quoted to round-trip safely.

  1. Input: {"flag": "true", "label": "Yes: maybe"}
  2. The string "true" would be read back as a boolean, so it is quoted.
  3. The string "Yes: maybe" contains a colon and space, which would look like a nested key, so it is quoted.
  4. Both are emitted with double quotes and proper escaping.

Result: flag: "true" label: "Yes: maybe"

How JSON structures map to YAML

JSONYAML equivalentNotes
{ "a": 1 }a: 1Object key becomes a key: value line
[1, 2, 3]- 1\n- 2\n- 3Array element becomes a dash line
{ "a": { "b": 1 } }a:\n b: 1Nested object indents one level
{ "a": [] }a: []Empty array stays inline
{ "a": {} }a: {}Empty object stays inline
nullnullNull is written as the word null

When a string value gets quoted in YAML

String valueOutputReason
LondonLondonPlain text, safe unquoted
true"true"Would parse as a boolean
42"42"Would parse as a number
Yes: maybe"Yes: maybe"Colon and space looks like a key
(empty string)""Empty value must be explicit

Common mistakes to avoid

  • Assuming numbers stored as strings stay strings. If your JSON has "port": "8080" (a string) the converter quotes it as "8080" so it stays text. If you wanted the number 8080, change the JSON to remove the quotes before converting.
  • Pasting JSON with trailing commas or comments. Standard JSON does not allow trailing commas or comments. If your input has them, the parser reports an error. Remove the trailing comma or comment line and convert again.
  • Mixing tabs and spaces in the original data. YAML forbids tabs for indentation, but that only matters when writing YAML by hand. This tool always indents with spaces, so the output is safe, just keep using its result rather than re-indenting with tabs.
  • Expecting key order to be sorted. The converter preserves the key order of your JSON object exactly as written. It does not alphabetize keys, so if you need sorted output, sort the JSON first.

Glossary

JSON
JavaScript Object Notation, a text format for data built from objects, arrays, strings, numbers, booleans, and null.
YAML
YAML Ain't Markup Language, a human-friendly data format that uses indentation instead of braces and brackets.
Map
A collection of key-value pairs, called an object in JSON and a mapping in YAML.
Sequence
An ordered list of values, called an array in JSON and written with dash lines in YAML.
Scalar
A single value that is not a container: a string, number, boolean, or null.
Plain scalar
A YAML string written without quotes, allowed only when it cannot be misread as another type or as syntax.

Frequently asked questions

How do I convert JSON to YAML?

Paste your JSON into the input box, choose an indent width (2 or 4 spaces), and click Convert to YAML. The tool parses the JSON and serializes it as indented YAML, which you can then copy. Everything runs in your browser, so your data is never uploaded.

Is my data sent to a server?

No. The conversion is 100% client-side vanilla JavaScript running in your browser. Your JSON never leaves your device, which makes the tool safe to use even with private or sensitive configuration.

Why are some of my strings wrapped in quotes?

A string is quoted only when leaving it bare would change its meaning. Values like true, 42, or null would be read back as a boolean, number, or null, and strings with a colon and space could be mistaken for a nested key. Quoting these keeps the YAML round-tripping to the same data.

What happens if my JSON is invalid?

The tool uses a strict JSON parser. If your input has a syntax error, such as a trailing comma, a missing quote, or a stray comment, it shows a clear error message instead of producing output. Fix the highlighted issue and convert again.

Does the converter keep my key order?

Yes. The output follows the exact order of keys in your JSON object. It does not sort or rearrange keys, so the YAML mirrors the structure you pasted in.

Can I convert YAML back to JSON?

Yes, use the companion YAML to JSON converter for the reverse direction. Because YAML is a superset of JSON, the data converts cleanly both ways as long as the YAML uses the common subset of maps, sequences, and scalars.