JSON ↔ YAML Converter
Convert between JSON and human-readable YAML in either direction.
What is JSON ↔ YAML Converter?
A JSON to YAML converter takes a JSON document and rewrites it as YAML 1.2, using indentation instead of braces and brackets to express structure, while preserving the original keys, values, and nesting. The reverse direction parses YAML and emits an equivalent JSON document.
This JSON to YAML converter runs both directions in your browser. Paste JSON, click Convert, and get YAML for Kubernetes manifests, GitHub Actions, or Ansible playbooks. Switch to YAML → JSON to flip a hand-edited config back to the JSON form an HTTP API expects. DevOps and backend teams use it to bridge JSON APIs with infrastructure tooling that speaks YAML.
Why use this JSON to YAML converter?
- Move config between API and infrastructure tooling. Convert an API export to YAML for
kubectl apply, or flip a YAML config to JSON for a service that does not parse YAML. - Read deeply nested data more easily. YAML’s indentation-based syntax is easier to skim than a tower of JSON braces, especially for configs with many small leaf values.
- Round-trip with confidence. The converter parses both formats with strict spec compliance, so going JSON → YAML → JSON yields the same data.
- Stay private by default. Conversion runs in your browser. The config never reaches a server, so secrets in
envblocks stay on your machine. - Skip the language switch. A quick conversion that would normally need
yqorpython -chappens in one paste and one click.
How to use the JSON to YAML converter
- Select the direction with the JSON → YAML or YAML → JSON toggle at the top.
- Paste your source into the input panel on the left.
- Click Convert.
- Copy the result from the output panel on the right.
Type-mapping table
| JSON | YAML | Notes |
|---|---|---|
{ "k": "v" } | k: v | Strings unquoted unless they look like other types. |
[1, 2, 3] | - 1- 2- 3 | Dash-prefixed block sequence. |
"true" (string) | "true" | Quoted to avoid being read as boolean. |
true (bool) | true | YAML 1.2 booleans (not yes/no). |
null | null | Also accepts ~ or empty value when parsing. |
42 | 42 | Numbers unquoted. |
YAML 1.2 narrowed the boolean keywords to true and false only (the older 1.1 spec accepted yes, no, on, off). The converter follows 1.2 to avoid the “Norway problem” where NO was read as boolean false.
Worked example
A Kubernetes-style JSON config:
{
"apiVersion": "v1",
"kind": "Service",
"metadata": { "name": "api", "labels": { "app": "shotmark" } },
"spec": {
"selector": { "app": "shotmark" },
"ports": [{ "port": 80, "targetPort": 8080 }]
}
}Converts to:
apiVersion: v1
kind: Service
metadata:
name: api
labels:
app: shotmark
spec:
selector:
app: shotmark
ports:
- port: 80
targetPort: 8080The round-trip back to JSON produces an identical structure with the same key order.
Common use cases
- DevOps engineers writing Kubernetes manifests. Convert a JSON API response from
kubectl get -o jsoninto YAML to commit into a GitOps repo. - Backend developers wiring CI workflows. Translate JSON config fixtures into the YAML form that GitHub Actions, GitLab CI, and CircleCI expect.
- Platform engineers maintaining Helm charts. Switch between JSON values overrides and YAML
values.yamlfiles without manual reformatting. - API consumers reading OpenAPI specs. Flip an OpenAPI JSON doc to YAML for hand-editing, then back to JSON for tooling that only accepts JSON.
- QA engineers preparing test fixtures. Edit YAML by hand because it is more readable, then convert to JSON for API integration tests.
Frequently asked questions
Is YAML a superset of JSON?
Effectively yes. YAML 1.2 was designed so that every valid JSON document is also a valid YAML document. That means you can rename a .json file to .yaml and most parsers will read it. The reverse is not true: YAML supports anchors, multi-document streams, and tag types that JSON does not.
Why does the YAML output quote some strings but not others?
The converter quotes strings that would otherwise be read as a different YAML type. The string "true" is quoted because unquoted true is a boolean. The string "123" is quoted because unquoted 123 is a number. Plain strings like Ada Lovelace need no quotes.
How does the converter handle nested arrays?
JSON arrays become YAML block sequences, with each element on its own line prefixed by -. Nested objects inside arrays indent another level. Arrays of arrays produce nested dash blocks, which are valid but harder to read than a flatter shape.
Can I convert YAML back to JSON?
Yes. Switch to the YAML → JSON mode and paste your YAML. The parser supports YAML 1.2 features including block scalars, anchors and aliases, and flow style. Anchors and aliases expand into duplicated values in the JSON output, since JSON has no reference type.
Does the converter preserve key order?
Yes. Both directions iterate keys in insertion order. This matters for tooling that diffs serialized output, like kubectl diff or GitOps pipelines, where a reordered field would show as a spurious change.
How are YAML comments handled?
YAML allows # line comments. JSON does not. When converting YAML to JSON, comments are dropped. There is no way to round-trip them through JSON, so keep your canonical config in YAML if comments matter.
What about YAML’s multi-document streams?
A YAML stream can contain several documents separated by ---. JSON has exactly one root value per document. The converter reads only the first YAML document and discards the rest. To convert a multi-document YAML file, split it first and convert each piece.
Related tools
- JSON Formatter & Diff: Pretty-print JSON and compare two payloads.
- JSON Validator: Check JSON syntax and pinpoint the exact line of any error.
- JSON Minifier: Strip whitespace and compress JSON to its smallest valid form.
- YAML Formatter: Pretty-print and validate YAML configuration files.
Related tools
JSON Formatter & Diff
Paste two JSON payloads and see the real diff with collapsible tree, key search, and copy-as-JSON-path.
Open toolJSON Validator
Paste JSON and instantly see if it's valid, with the exact line and character of any error.
Open toolJSON Minifier
Strip whitespace and compress JSON to its smallest valid form.
Open toolShotMark captures what you do here, in one click.
The traces, payloads, and tests you run by hand? ShotMark grabs the whole bug and hands it to your AI agent.