/ developer & network toolbox
← all tools

$ yaml

runs locally

JSON ↔ YAML

Convert between JSON and YAML, both directions, in your browser.

yaml — invoker.tools

Converts in your browser — nothing is uploaded.

About the JSON ↔ YAML

This tool converts data between JSON and YAML in both directions using a full YAML parsing library, so nested objects, arrays, strings, numbers, booleans and null all map across correctly whichever way you convert.

JSON is the format most APIs and programming languages speak natively, while YAML is what most configuration systems use instead, Kubernetes manifests, GitHub Actions and other CI pipelines, Docker Compose files, Ansible playbooks, so translating between the two is a routine task for anyone who works across both.

It runs entirely in your browser through a YAML library bundled into the page, so configuration data, including anything sensitive hiding in a manifest like a connection string, never leaves your machine. When the input does not parse, the error names the actual problem rather than failing silently.

JSON to YAML is always a faithful conversion, since JSON has no feature that YAML cannot represent. YAML to JSON can lose information, because YAML supports several things JSON has no syntax for at all, comments, anchors, multi-document streams. The sections below cover exactly what that means in practice.

How to use it

  1. Choose the direction: JSON to YAML or YAML to JSON.
  2. Paste your source data into the input box.
  3. Click convert to run the transformation.
  4. Read the parse error if the input is not valid JSON or YAML.
  5. Copy the converted output with one click.
  6. Switch direction and convert the result back to confirm a clean round trip.

Examples

  • Convert {"name":"invoker","tags":["dns","tls"]} into name: invoker with a tags: block listing dns and tls.
  • Paste a Kubernetes Deployment manifest in YAML and convert it to JSON for a tool that only accepts JSON.
  • Convert an API's JSON response into readable YAML to compare it against a config file by eye.
  • Round-trip a YAML file through JSON and back to reformat and validate its indentation.
  • Convert a GitHub Actions workflow step from YAML into JSON to feed into a script that edits it programmatically.
  • Convert a Docker Compose service block to JSON to check exactly which keys and values it actually contains.

What survives the round trip, and what doesn't

For the data types both formats share, objects, arrays, strings, numbers, booleans and null, the conversion is faithful in either direction. The gaps only appear when converting from YAML to JSON, because YAML supports several features JSON simply has no syntax for.

  • Comments (# lines): valid in YAML, no equivalent in JSON, dropped when converting YAML to JSON
  • Anchors and aliases (&name / *name, YAML's way to reuse a block): resolved to their expanded values rather than kept as references once converted to JSON
  • Multiple documents in one YAML file (separated by ---): only a single document is converted at a time, so a multi-document file needs to be split first

JSON to YAML is always lossless, YAML to JSON is not

JSON is effectively a strict subset of what YAML can express structurally, so any valid JSON already has a faithful YAML rendering with nothing left out. YAML's extra features cut the other way: they can't come back once flattened into JSON, which is why the two directions behave differently even though they share the same conversion engine.

  • Non-string map keys: YAML allows keys like 1: or true:, which become the strings "1" and "true" once represented in JSON, since JSON requires string keys
  • Explicit type tags (like !!str or a custom tag): resolved to their plain value, the tag itself is not preserved in JSON
  • Folded and literal block scalars (> and |): converted to the resulting plain string; the original line-folding style is not preserved

Common conversion errors

Most parse errors trace back to one of a handful of YAML quirks that either look fine to the eye or are easy to paste in from a JSON source by mistake.

  • Tabs in YAML indentation: the YAML spec forbids tabs for indentation entirely, so the parser reports an error rather than guessing at the intended structure
  • The Norway problem: an unquoted no or yes in YAML parses as the boolean false or true rather than a string, so quote them ("no", "yes") if you actually mean the word
  • Trailing commas or single-quoted strings pasted into the JSON to YAML direction: valid-looking JavaScript, but invalid JSON, reported as a parse error before any conversion happens

Frequently asked questions

Is the conversion lossless?

For standard data types (objects, arrays, strings, numbers, booleans, null) the conversion is faithful in both directions. YAML-only features like comments and anchors are not preserved when converting to JSON, which has no equivalent syntax.

Why do I get a parse error?

The input is not valid JSON or YAML. The error message names the problem, a syntax error or bad indentation, for example, so you can fix the offending line.

Does YAML support comments?

Yes, YAML allows # comments, but JSON does not, so any comments are dropped when converting YAML to JSON.

Is my data uploaded?

No. The conversion uses a YAML library that runs entirely in your browser.

What is the difference between JSON and YAML?

JSON is a compact, strict data format used by most APIs. YAML is a more permissive superset built for humans to read and write by hand, with comments, anchors and looser quoting, which most configuration tools use instead.

Why did "no" turn into false in my converted JSON?

This is the well-known Norway problem: unquoted no, yes, on and off are interpreted as booleans by the YAML spec. Quote the word ("no") in the YAML source if you want it to stay a string.

Can I convert a Kubernetes manifest with this tool?

Yes. A single Kubernetes manifest is just a YAML mapping, so it converts to JSON the same way any other YAML document does.

Does it support multiple YAML documents in one file, separated by ---?

It converts one document at a time. Split a multi-document file at its --- separators and convert each document individually.

Why does my YAML fail to parse when it looks correctly indented?

Check for tab characters. YAML indentation must use spaces only; a tab that looks fine visually will still be rejected by the parser.

Are YAML anchors and aliases preserved when converting to JSON?

No. Anchors and aliases are resolved to their expanded values during conversion, since JSON has no way to represent a reference back to another part of the document.

More convert tools