Dev Tools Convert JSON to YAML Converter
100% client-side · No signup · Free forever

JSON to YAML Converter

Convert JSON into clean YAML for Kubernetes manifests, GitHub Actions, and config files.

1
Convert tool
JSON to YAML Converter
Live
Input
YAML Output

YAML (YAML Ain't Markup Language) is the dominant config format for cloud-native tooling — Kubernetes manifests, GitHub Actions workflows, GitLab CI pipelines, Docker Compose files, Helm charts, Ansible playbooks, OpenAPI specs — all YAML. But APIs and applications natively speak JSON, so converting between the two is a daily task. This JSON to YAML converter produces clean, idiomatic YAML with proper indentation, quoted strings only when necessary, and array notation that matches common style guides.

How JSON to YAML Conversion Works

The converter parses your JSON into a JavaScript object, then walks the object tree emitting YAML syntax: objects become key-colon-value pairs, arrays become hyphen-prefixed lists, and primitives are emitted as-is with quoting only when the value contains special YAML characters (:, #, leading/trailing whitespace, or characters that would otherwise be interpreted as booleans/numbers). The output uses 2-space indentation, which matches the Kubernetes, Ansible, and most YAML style guides.

When to Convert JSON to YAML

  • Kubernetes manifests — convert kubectl get -o json output to YAML for committing to Git.
  • Helm chart values — start from a JSON config, emit YAML for values.yaml.
  • GitHub Actions — generate workflow YAML programmatically from JSON definitions.
  • Docker Compose — build docker-compose.yml from a JSON service map.
  • OpenAPI / Swagger — specs are interchangeable JSON or YAML; humans usually prefer YAML.

JSON to YAML in Code

// Browser / Node: use the 'js-yaml' library
const yaml = require('js-yaml');
const yamlStr = yaml.dump(JSON.parse(jsonInput));

// CLI: with yq (Go version)
// echo '{"foo": "bar"}' | yq -P

// CLI: with Python and PyYAML
// python -c "import json,sys,yaml; print(yaml.dump(json.load(sys.stdin)))"

For the reverse direction, use our YAML to JSON converter.

YAML Gotchas to Avoid

YAML has several footguns: (1) the Norway problem — unquoted NO is parsed as boolean false in YAML 1.1, so country codes and similar two-letter strings should be quoted; (2) octal numbers012 is interpreted as octal 10 in YAML 1.1; (3) tabs are forbidden for indentation — always use spaces; (4) trailing whitespace can change parsing. This converter quotes any value that would be ambiguous, so the round-trip JSON → YAML → JSON preserves the original data exactly.