ShotMark
Skip to Content

JSON ↔ YAML Converter

Convert between JSON and human-readable YAML in either direction.

JSON Input
YAML Output
Waiting for input

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 env blocks stay on your machine.
  • Skip the language switch. A quick conversion that would normally need yq or python -c happens in one paste and one click.

How to use the JSON to YAML converter

  1. Select the direction with the JSON → YAML or YAML → JSON toggle at the top.
  2. Paste your source into the input panel on the left.
  3. Click Convert.
  4. Copy the result from the output panel on the right.

Type-mapping table

JSONYAMLNotes
{ "k": "v" }k: vStrings 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)trueYAML 1.2 booleans (not yes/no).
nullnullAlso accepts ~ or empty value when parsing.
4242Numbers 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: 8080

The 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 json into 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.yaml files 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.

Like this tool?

ShotMark 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.

Private beta accessFounding pricing lockNo spam ever