# YAML ↔ JSON Converter

> Convert YAML to JSON or JSON to YAML in your browser. Handles multi-document files (---), keeps dates as written, clear errors with the line. Nothing uploaded.

Canonical: https://cromagnon.app/tools/yaml-json
Last updated: 2026-10-25

- Category: Developer
- Formats: YAML · JSON
- Use it: https://cromagnon.app/tools/yaml-json (free, runs in the browser)

## What it does

Convert YAML to JSON or JSON to YAML in either direction. YAML is the format of Docker Compose, Kubernetes, GitHub Actions and many app configs; JSON is what APIs and JavaScript use. Files with several YAML documents (separated by ---) become a JSON array, and dates stay exactly as written.

## How to use it

1. Choose the direction: JSON → YAML or YAML → JSON.
2. Paste your text into the Input box.
3. Pick the indent (2, 4 or 8 spaces; tabs for JSON).
4. Read the status line, then copy or download the result.

Tip: YAML is sensitive to indentation: use spaces, never tabs, and keep items of the same list at the same depth.

## YAML and JSON side by side

Both describe the same things (objects, lists, text, numbers, true/false and null), just written differently.

- **Objects**: YAML: name: Ali on its own line. JSON: {"name": "Ali"}.
- **Lists**: YAML: lines starting with “- ”. JSON: ["a", "b"].
- **Text**: YAML often needs no quotes; JSON always uses double quotes.
- **Comments**: YAML allows # comments; JSON has none, so comments are dropped when converting to JSON.

## Several documents in one file

Kubernetes manifests often put several objects in one file, separated by lines of ---. Converting to JSON gives an array with one item per document, and the status line says how many there were.

To go back, convert a JSON array to YAML; you get a single YAML list, which you can split into documents by hand if your tool needs them separate.

## Dates, yes/no and other surprises

- **Dates stay as text**: released: 2026-10-26 becomes "2026-10-26", not a full timestamp with a time zone.
- **yes and no stay text**: This converter follows YAML 1.2, where only true and false are booleans, so a country code like NO isn't turned into false.
- **Long strings aren't folded**: When converting to YAML, long text stays on one line instead of being wrapped.
- **No anchors**: Repeated parts are written out in full, which every YAML reader understands.

## Common YAML errors

A tab used for indentation, a list item at the wrong depth, a colon inside unquoted text (url: http://x:8080 is fine, but key: a: b is not), or text starting with @ or a backtick. The error message gives the line and column; quote the value if in doubt.

## Converting a Docker Compose or Kubernetes file

Paste the whole file and choose YAML → JSON. Each service, container or port becomes an object or a list in JSON, which shows exactly how the tool will read it. If a setting seems ignored, look for it in the JSON: if it sits under the wrong parent, its YAML line is indented one level off.

A Kubernetes file with a Deployment and a Service separated by --- comes out as a JSON array of two objects, in the same order.

## Multi-line text in YAML

- **Literal block (|)**: Keeps line breaks exactly: good for scripts, certificates and messages. In JSON the breaks become \n.
- **Folded block (>)**: Joins lines with spaces into one long line, with a blank line marking a new paragraph.
- **Quoted text**: Use double quotes when text contains a colon followed by a space, a # or starts with a special character.

## YAML data types at a glance

- **Text**: name: Ali, or "Ali: the admin" in quotes when it contains a colon and a space.
- **Numbers**: port: 8080 and ratio: 0.75 become JSON numbers; quote them ("8080") to keep them as text.
- **true / false**: Only true and false (any case) are booleans here; yes, no, on and off stay text.
- **null**: null, ~ or an empty value become JSON null.
- **Lists**: Lines starting with “- ”, or inline [a, b, c].
- **Objects**: Indented key: value pairs, or inline {a: 1, b: 2}.

## Tips

- **Check a GitHub Actions workflow**: Convert it to JSON to see exactly how the runner reads your steps.
- **Write configs in YAML, ship JSON**: Keep a readable YAML file and convert it for tools that only accept JSON.
- **Spot an indentation bug**: If a key ends up in the wrong place in the JSON, its YAML line is indented one level off.
- **Quote version numbers**: version: 1.10 becomes the number 1.1; write version: "1.10" to keep it as text.
- **Validate before deploying**: A YAML error at deploy time is slow to debug; converting first catches it in a second.
- **Keep secrets local**: Nothing is uploaded, so config files with keys and passwords stay on your device.

## Questions

### Are comments kept?

No. JSON has no comments, so YAML comments are dropped when converting to JSON.

### Can it convert a file with several YAML documents?

Yes. Documents separated by --- become a JSON array, one item per document.

### Why did my date change?

It doesn't here: dates are kept exactly as written. Other converters may turn them into timestamps.

### Is YAML a superset of JSON?

Mostly: almost every JSON file is also valid YAML 1.2, so a YAML reader can usually read JSON directly.

### Which indentation should I use?

Two spaces is the most common style for both YAML and JSON.

### Does it support anchors and aliases?

Yes, when converting YAML to JSON: an alias (*name) is replaced by a copy of what its anchor (&name) points to, because JSON has no references.

### Can I use tabs in YAML?

No. The YAML standard forbids tabs for indentation; use spaces. Tabs are fine inside quoted text.

### Why is my value a number instead of text?

YAML reads unquoted digits as numbers, so a ZIP code 01234 or version 1.10 changes. Put the value in quotes to keep it exactly as text.

### Is my data uploaded?

No. The tool runs in your browser; what you paste or open never leaves your device and nothing is stored on a server.

## Related

- [JSON Formatter](https://cromagnon.app/tools/json-formatter)
- [XML Formatter](https://cromagnon.app/tools/xml-formatter)
- [JSON ↔ CSV Converter](https://cromagnon.app/tools/json-csv)
- [Cron Expression Parser](https://cromagnon.app/tools/cron-parser)
- [All tools](https://cromagnon.app/tools)
