JSON to YAML converter

Convert JSON into YAML instantly

Paste JSON on the left and get YAML on the right — all in your browser

Last updated: January 26, 2026
Frank Zhao - Creator
CreatorFrank Zhao
The converted YAML will appear here

Introduction / overview

The JSON to YAML converter takes JSON (or JSON5-style JSON) on the left and generates YAML on the right. It’s a fast way to turn dense API payloads into something you can read and edit comfortably.

Use it when you need a human-friendly version of a JSON payload — for configuration files, code reviews, or quick debugging.

Why it’s safe and reliable

  • Runs locally in your browser — your input isn’t uploaded to a server.
  • Validates the JSON and shows an error when it can’t be parsed.
  • Outputs clean YAML that’s easier to diff and review.

If you’re moving data in the opposite direction, try our YAML to JSON converter. If your end goal is a config format, you may also like YAML to TOML.

How to use / quick start

1

Paste your JSON

Paste JSON (or JSON5) into the left box. JSON5 is helpful if your snippet has single quotes, trailing commas, or comments.

2

Check validation

If the converter says “Provided JSON is not valid”, fix the first syntax issue (missing quotes, trailing braces, etc.).

3

Copy the YAML output

Click the copy button on the right to paste YAML into a file (like .yml\texttt{.yml}) or a config editor.

A tiny sanity-check you can do

If your JSON has nn top-level keys, you should usually see about the same number of “top-level” YAML lines (unless some values are nested).

nkeys=4n_{\text{keys}} = 4\Rightarrowexpect roughly 4 top-level YAML entries\text{expect roughly }4\text{ top-level YAML entries}

It’s not a strict rule, but it’s a quick way to catch a missing brace or a pasted fragment.

Step-by-step examples

Example 1: A small API payload

Imagine you have a response with a user and a list of roles. You paste JSON on the left, then copy YAML from the right.

Inputs (counts)

Top-level keys

nkeys=3n_{\text{keys}} = 3

Role items

nroles=2n_{\text{roles}} = 2

Preferred indent

i=2i = 2

You’re not “calculating” YAML — but these numbers help you sanity-check the shape after conversion.

nentries=nkeys+nrolesn_{\text{entries}} = n_{\text{keys}} + n_{\text{roles}}==3+23 + 2==55

If you only see one YAML line after conversion, it usually means the JSON failed to parse or you pasted a truncated snippet.

Reading the YAML output: arrays become dash-prefixed lists, and objects become key/value blocks. If you prefer to inspect the structure as JSON again, switch directions with our YAML to JSON converter.

Example 2: JSON5-style snippets from logs

Many logs and code snippets aren’t strict JSON. They might include single quotes or trailing commas. This tool accepts JSON5, so these snippets can still convert cleanly.

Quick check (nesting depth)

If you have a nested object three levels deep, expect indentation to show that depth.

d=3d = 3\Rightarrowindentation roughly id=23\text{indentation roughly } i\cdot d = 2\cdot 3==6 spaces6\ \text{spaces}

Not every YAML serializer uses the same style, but depth-based indentation is the main thing to look for.

If a snippet still fails, try removing comments, or wrap unquoted keys in quotes so they become valid JSON5.

Real-world examples / use cases

Turn an API request into a readable config snippet

You copied a JSON request body from a REST client and want to paste it into a YAML-based deployment tool.

Keys

nkeys=6n_{\text{keys}} = 6

Arrays

narrays=2n_{\text{arrays}} = 2

Result

YAML makes nested data skimmable\text{YAML makes nested data skimmable}\Rightarrowfaster review in PRs\text{faster review in PRs}

After conversion, you can quickly spot missing fields or wrong types before you commit. For comparing edits, YAML is often easier to diff.

Related: YAML to JSON converter

Convert JSON secrets into YAML templates (carefully)

You need a template file but want to avoid accidentally leaking secrets when sharing a snippet with teammates.

Secret fields

nsecrets=3n_{\text{secrets}} = 3

Share size limit

Lmax6000L_{\max} \approx 6000

Result

mask secrets before sharing\text{mask secrets before sharing}\Rightarrowuse placeholders like TOKEN\text{use placeholders like }\langle\text{TOKEN}\rangle

Replace real tokens with placeholders in JSON first, then convert to YAML. This keeps the YAML example safe for docs and tickets.

Related: Hash Text

Make large JSON logs easier to skim

A debug log dumps a huge JSON object, and you want a faster way to find what changed between runs.

Depth

d4d \ge 4

Objects

nobj1n_{\text{obj}} \gg 1

Result

indentation highlights structure\text{indentation highlights structure}\Rightarrowfaster manual diff\text{faster manual diff}

Convert both versions to YAML, then compare the YAML in your editor. Human-friendly formatting reduces “brace noise”.

Related: YAML to TOML

Common scenarios / when to use

Writing YAML-based configs

You need to turn a JSON object into a config snippet for tools that prefer YAML files.

Cleaner code reviews

YAML often makes nested fields easier to scan than dense JSON with lots of braces.

Docs and tutorials

You want examples that readers can understand quickly, without missing a comma.

Quick transformations in the browser

You don’t want to install CLI tools just to convert a snippet once.

When you should not use it

For extremely large payloads or sensitive secrets you cannot expose on your screen, a local CLI might be safer.

When YAML isn’t ideal

If the receiving system strictly requires JSON (or exact ordering/format), keep it as JSON.

A good workflow is: convert JSON → YAML for readability, edit the YAML, then convert back with YAML to JSON converterso your final payload is strict JSON.

Tips & best practices

Keep YAML friendly, not clever

  • Prefer plain scalars for simple values; avoid over-quoting unless you need it.
  • If you edit YAML, run it back through YAML to JSON converterbefore shipping.
  • Watch out for values that look like booleans or numbers. Quote them if the receiver expects a string.

Pro tip: treat conversion as a two-step workflow

Convert JSON → YAML to make edits, then convert YAML → JSON again for strict machine consumption. Think of it like working in a “draft format”.

JSONYAMLJSON\text{JSON} \to \text{YAML} \to \text{JSON}\Rightarrowreadable edits + strict final output\text{readable edits + strict final output}

Calculation method / mapping

This converter applies a simple mapping from JSON values to YAML. Conceptually, it’s a function ff that transforms a JSON value into a YAML document.

f:JYf: J \to Y

Where JJ is “a JSON value” and YY is “a YAML document”.

Core mapping rules (intuitive version)

{}\{\ldots\}\mapstoYAML mapping (key: value)\text{YAML mapping (key: value)}\qquad[][\ldots]\mapstoYAML sequence (- item)\text{YAML sequence (- item)}
  • Objects become YAML mappings: kvk \mapsto v becomes k:vk: v.
  • Arrays become YAML sequences: items appear on lines starting with -.
  • Strings, numbers, booleans, and null\texttt{null} become YAML scalars.

Tip: YAML can be more “interpretive” than JSON. If a value must stay a string (like "0012""0012"), quote it.

Related concepts / background

JSON vs YAML (quick mental model)

  • JSON is strict: great for machines, less forgiving for humans.
  • YAML is flexible: great for configs and readability, but you must be careful with quoting and indentation.

Common “gotchas” worth knowing

  • Leading zeros can be tricky: 0012\texttt{0012} may look numeric. Quote if it must remain a string.
  • Dates can be interpreted by some YAML parsers. If you need a literal string, quote it.
  • Large numbers: if precision matters, keep them as strings or validate downstream.

Working with other formats? You might also use our Base64 string encoder/decoderwhen transporting JSON safely inside URLs or headers.

Frequently asked questions

Why does it say “Provided JSON is not valid”?

Most often it’s a missing quote, an extra comma, or a truncated snippet. Start from the first error: make sure braces match and strings are properly quoted. If your snippet is “almost JSON” (comments, single quotes), JSON5 support helps — but some very custom formats still won’t parse.

Does this tool support JSON5?

Yes. It can parse JSON5-style input, which can accept things like trailing commas. You can think of it as parsing a broader language J5\mathcal{J}_{5} that contains standard JSON J\mathcal{J}.

JJ5\mathcal{J} \subseteq \mathcal{J}_{5}

Will YAML preserve the exact formatting of my JSON?

It preserves the data, not the original whitespace. YAML output will be re-serialized with consistent indentation. If you need a byte-for-byte stable format for hashing, keep the original JSON and use tools like minifiers/formatters instead.

Why do some values appear quoted in YAML?

Quoting is used when a plain scalar could be ambiguous. For example, a string that looks like a number might be quoted to keep it safe for parsers.

Can I convert back to JSON after editing the YAML?

Yes — that’s a great workflow. Convert JSON → YAML to edit comfortably, then convert YAML → JSON again using our YAML to JSON converter.

Does key order stay the same?

In many cases it will, but you shouldn’t rely on it as a strict guarantee across tools and platforms. If order matters, store your data as a list of entries rather than a mapping.

Limitations / disclaimers

Important notes

  • This tool converts formats; it does not validate against your application’s schema.
  • YAML parsing/interpretation can vary across environments. Always test with the same YAML parser your target system uses.
  • Don’t paste sensitive secrets into any tool if you can’t risk them being visible on your screen.

For sensitive workflows, a local CLI in an isolated environment may be a better option.

External references / sources

If you want to go deeper, these specs and docs explain the underlying formats:

Want to explore related tools? Browse the Conversioncategory.

JSON to YAML converter | CalculatorVast