CodeKitHub
JSON Tools

JSON ↔ YAML Converter

Last updated:

To convert JSON to YAML, objects become indented key: value blocks and arrays become `-` prefixed list items — the reverse conversion resolves YAML type shortcuts like unquoted true, null or numbers back into proper JSON types. This tool does that conversion, in both directions, entirely in your browser.

What Is This Tool?

YAML is the format of choice for most modern configuration files — Kubernetes manifests, Docker Compose, GitHub Actions and GitLab CI pipelines, Ansible playbooks — because it's more readable than JSON for humans editing files by hand: no quotes required around most keys, no trailing commas to get wrong, and comments are supported. JSON, meanwhile, is what most APIs and programming languages produce and consume natively.

This tool bridges the two using js-yaml, a widely used JavaScript implementation of the YAML specification, so parsing and generation follow the same rules a YAML-aware tool like `kubectl` or a CI runner would apply.

Converting JSON to YAML turns objects into indented key: value blocks and arrays into `-` prefixed list items. Converting YAML to JSON does the reverse, and also resolves YAML-specific type shortcuts (like unquoted `true`, `null`, or numbers) into their proper JSON types.

Why Use It?

  • Bidirectional — convert JSON to YAML or YAML to JSON from the same screen.
  • Standards-based parsing and generation via js-yaml, so the output matches what real YAML tooling (Kubernetes, CI systems, Ansible) expects.
  • Handles nested objects and arrays at any depth, converting between YAML's indentation-based structure and JSON's braces and brackets.
  • Correctly interprets YAML type shortcuts — unquoted true/false, null, and numeric values become their proper JSON types rather than strings.
  • Copy to clipboard or download as a .json or .yaml file.
  • 100% client-side — nothing you paste is uploaded anywhere.

How to Use

  1. Choose a direction: "JSON → YAML" or "YAML → JSON".
  2. Paste your data into the input box.
  3. Click "Convert".
  4. Review the result, then copy it or click "Download" to save a file.

Example

Input

{"name":"Alice","roles":["admin","editor"],"active":true}

Output

name: Alice
roles:
  - admin
  - editor
active: true

Note how the array becomes a list of dashed items under "roles", and the boolean stays unquoted true rather than becoming the string "true".

Practical tips

  • Writing a Kubernetes manifest or GitHub Actions workflow: draft the structure as JSON (many editors and AI tools generate JSON more reliably), then convert to YAML for the final file.
  • Debugging a YAML config that's misbehaving: convert it to JSON to see exactly which values are strings, numbers, or booleans — YAML's flexible syntax can hide type mismatches that are obvious in JSON.
  • If your JSON contains keys with special characters or that start with a number, js-yaml will automatically quote them in the YAML output so they parse back correctly.

Why type coercion is the trickiest part of YAML

YAML's biggest usability win over JSON — not requiring quotes around most values — is also its biggest source of subtle bugs. The classic example is the "Norway problem": in YAML 1.1 (used by many older parsers), an unquoted value of `no` is interpreted as the boolean `false`, not the string "no", which has broken real-world country-code configs listing Norway. This tool follows the YAML 1.2 specification, which narrowed the set of unquoted values treated as booleans to just `true` and `false` (and their case variants), reducing — though not eliminating — this class of surprise. When in doubt about how a value will be typed, quoting it explicitly in your YAML is the safest choice.

Frequently Asked Questions

Are YAML comments preserved when converting to JSON and back?

No. JSON has no concept of comments, so converting YAML to JSON discards any # comments in the source. If you convert that JSON back to YAML, the comments won't reappear — this is an inherent limitation of the format, not a bug in the tool.

How does the tool handle YAML anchors and aliases (& and *)?

The underlying parser (js-yaml) resolves anchors and aliases before producing JSON, so a YAML file using & anchors and * aliases to reuse a block of data will convert to JSON with that data expanded in full at every place it's referenced.

Why did my YAML number come through as a string in JSON, or vice versa?

If a value is quoted in the YAML source (e.g. version: "3.10"), it's treated as a string on purpose — this matters because unquoted YAML numbers like 3.10 can lose the trailing zero when parsed as a float. Quote a value in the source YAML if you specifically need it treated as text.

Can I convert a YAML file with multiple documents (separated by ---)?

This tool converts a single YAML document at a time. If your file has multiple documents separated by --- markers, convert one section at a time, or remove the separators and merge them into one document first if that fits your use case.

Is my data uploaded anywhere?

No. The conversion runs entirely in your browser via the js-yaml library — nothing is sent to a server, which makes it safe to use with real configuration files, including ones with internal hostnames or infrastructure details.

Related Tools