DevPik Logo

JSON to YAML Converter

Convert JSON to YAML and YAML to JSON for Docker Compose, Kubernetes manifests, GitHub Actions and CI configs. Anchors, merge keys, block strings and multi-document files are handled, strings that look like numbers or booleans stay strings, and anything JSON cannot hold is listed.

Built and maintained by Muhammad Tayyab — Founder, DevPik.

Why Use JSON to YAML Converter?

Docker Compose, Kubernetes manifests, GitHub Actions, and CircleCI all expect YAML. APIs and npm scripts return JSON. Any time you move config between those worlds you need a converter, and config often holds hostnames and secrets you would rather not upload. This converter runs locally, so a map nested inside a list item stays nested, a `run: |` script keeps every line, and strings a parser would read as something else (`y`, `no`, `1.10`, `2024-01-15`) are quoted. Useful when translating an API payload into an Ansible variables file, or the other way when scaffolding a new workflow.

How to Use JSON to YAML Converter

  1. Paste your JSON into the left input panel. The tool converts it to YAML in real-time as you type.
  2. Adjust formatting options: choose 2 or 4 space indentation, put arrays of up to five plain values on one line with Inline arrays, or quote every string.
  3. Click the Swap button to switch to YAML → JSON mode and convert YAML back to JSON. A note under the output lists anything JSON could not keep, such as comments.
  4. Copy the output to your clipboard or download it as a .yaml or .json file.

Worked Examples

JSON API response → Kubernetes env block

Input
{ "env": [ { "name": "DB", "value": "postgres" } ] }
Output
env:
  - name: DB
    value: postgres

Output is ready to paste into a Deployment manifest's container spec.

YAML config → JSON for an API PATCH

Input
version: 1
settings:
  debug: true
Output
{
  "version": 1,
  "settings": {
    "debug": true
  }
}

The JSON uses the indent you pick, 2 spaces here. Comments in the YAML would be removed, and the note under the output says how many.

Preserve multi-line string in YAML

Input
{ "banner": "Line one\nLine two" }
Output
banner: |-
  Line one
  Line two

The block scalar `|-` syntax is YAML's idiomatic way to preserve newlines.

About JSON to YAML Converter

The JSON to YAML Converter is a free online tool that converts between JSON and YAML formats instantly. JSON (JavaScript Object Notation) and YAML (YAML Ain't Markup Language) are both popular data serialization formats, but they serve different purposes. JSON is the standard for APIs and data exchange, while YAML is preferred for configuration files like Docker Compose, Kubernetes manifests, GitHub Actions workflows, and CI/CD pipelines because of its human-readable syntax and support for comments. Both directions run on js-yaml. They handle nested objects and arrays, nulls, booleans, multi-line block strings, anchors, aliases and merge keys, and files with several documents, and a malformed file is reported with the line and column of the problem instead of being half converted. Customize the output with indent size options and inline array formatting. Everything runs in your browser, so your data never leaves your device.

Troubleshooting & Common Issues

YAML output quotes values that look fine

Some plain words and numbers mean something else to a YAML parser: `true`, `null`, `~`, `1.10` and `2024-01-15` change type, and YAML 1.1 parsers such as PyYAML and Ansible also read `yes`, `no`, `on`, `off`, `y` and `n` as booleans. The converter quotes any string one of these rules would change, so `"no"` stays the text no in every parser. The quotes are not part of the value.

Indentation errors when parsing YAML → JSON

YAML is whitespace-sensitive: a key one space out of line with its neighbours, or a tab used for indentation, breaks the parse. The error message gives the line and column, for example "Line 3, column 5: bad indentation of a mapping entry". Indent with spaces only, 2 or 4 per level, and line each key up with the keys beside it.

Comments from YAML disappeared in JSON

JSON has no comments, so they cannot survive the conversion; the note under the output counts how many were removed. If a note must travel with the data, put it in a field such as `_comment`.

A version like 1.10 turned into 1.1

Unquoted, `1.10` is the number 1.1 to every YAML parser. Going JSON to YAML, the converter quotes `"1.10"` for you. Going YAML to JSON, the value is already a number by the time it reaches JSON, so quote it in the YAML: `version: "1.10"`. A version with two dots, such as `1.2.30`, is not a number and stays text either way.

Frequently Asked Questions

How do I convert JSON to YAML?

Paste your JSON into the left input panel and the tool instantly converts it to YAML in the right panel. You can customize the output with 2 or 4 space indentation, inline short arrays, and string quoting options. Copy or download the result when ready.

Can I convert YAML to JSON?

Yes. Click the Swap button to switch to YAML → JSON mode and paste your YAML in the left panel. Aliases are replaced by full copies of their anchored values, merge keys (<<) are folded into the map, block strings such as a `run: |` script keep every line, and a file with several documents separated by --- becomes a JSON array. Comments are removed because JSON has none, and a note under the output lists everything that could not be kept.

What is the difference between JSON and YAML?

JSON uses braces {} and brackets [] with strict syntax, while YAML uses indentation-based structure that's more human-readable. YAML supports comments, JSON doesn't. JSON is standard for APIs and JavaScript, while YAML is preferred for configuration files (Docker, Kubernetes, GitHub Actions). Both represent the same data structures.

Does the converter handle nested objects and arrays?

Yes. Maps inside lists inside maps, such as a Kubernetes container's resources.limits or a GitHub Actions step's with: block, keep their nesting in both directions, along with arrays of arrays, nulls, booleans, numbers and multi-line strings.

Will the YAML work in Kubernetes, Docker Compose or GitHub Actions?

The output is standard block-style YAML with 2 or 4 space indentation, nested maps under list items and `|` blocks for multi-line strings, which those tools read as-is. Their schema rules (required fields, allowed keys) are not checked, so validate the result with `kubectl apply --dry-run=client -f`, `docker compose config` or your CI's linter.

Is YAML a superset of JSON?

Under YAML 1.2, yes: JSON's braces, brackets and double-quoted strings are all legal YAML, so a YAML 1.2 parser can read a JSON file directly. They still have different conventions and strengths. YAML adds comments, anchors and aliases, and multi-line block strings, none of which JSON supports. This tool converts between their conventional formats.

Is my data safe when converting?

Yes. This JSON to YAML converter runs entirely in your browser. Your JSON and YAML are never sent to a server and stay on your device.

Guides & Further Reading

Related Tools

Was this tool helpful?