Aa
JSON & Code

JSON to YAML Converter — Transform JSON Data to YAML Format

The Kubernetes docs show a JSON example but your manifest file needs YAML — this JSON to YAML converter handles it in one paste. Curly braces and quotes disappear; indentation and colons take their place: {"name":"nginx","port":80} becomes "name: nginx port: 80". DevOps engineers use it to convert JSON API snippets into docker-compose.yml and GitHub Actions workflows, developers use it to write OpenAPI specs, and data teams use it for Airflow and dbt configs. No signup needed.

Advertisement
0 words0 chars
Advertisement

What Is JSON to YAML Converter?

A JSON to YAML converter transforms JSON data into YAML format — taking structured JSON with curly braces, square brackets, and quoted strings and converting it to YAML's cleaner, indentation-based syntax. JSON and YAML represent the same data structures; YAML is simply easier for humans to read and write, which is why it is the default configuration format for Docker Compose, Kubernetes, GitHub Actions, Ansible, and most modern DevOps tools.

Paste your JSON and get valid YAML output instantly. The converter handles nested objects, arrays, strings, numbers, booleans, and null values — producing properly indented YAML that is ready to use in configuration files.

Example
{"name":"John","age":30}name: John age: 30

Before & After: JSON to YAML Converter Examples

Real input → output pairs showing exactly what this tool does to your text.

InputJSON to YAML Converter Output
{"name":"nginx","port":80}name: nginx port: 80
{"tags":["web","api","v2"]}tags: - web - api - v2
{"active":true,"count":null}active: true count: null
{"url":"https://example.com"}url: "https://example.com"
{"a":{"b":{"c":1}}}a: b: c: 1

Key Features

Idiomatic YAML 1.2 Output

YAML 1.2 (2009, yaml.org) formally defines JSON as a valid subset of YAML — all valid JSON is valid YAML 1.2. This converter produces YAML 1.2-compliant output: 2-space indentation, unquoted safe strings, quoted strings when values contain YAML-special characters (: # & * ? | < > { } [ ]), and null/true/false without quotes.

Removes JSON Visual Noise

Curly braces, square brackets, double quotes around keys, and commas between values all disappear. {"name":"nginx","port":80} becomes the three-character pair "name: nginx" — readable at a glance. Kubernetes, GitHub Actions, and Ansible chose YAML specifically because the reduced punctuation makes large config files manageable.

Config-File Ready

Output matches the indentation style and quoting conventions expected by Kubernetes kubectl apply, Docker Compose, GitHub Actions .yml, Ansible playbooks, Helm values.yaml, and OpenAPI spec files — ready to paste or save as .yaml without further editing.

Preserves Nested Structure — Objects and Arrays Converted Correctly

No upload, no account. Paste your JSON, copy the YAML — your config data stays on your device.

When to Use JSON to YAML Converter

✓ Use it for

Use when migrating configuration from JSON to YAML, writing Kubernetes manifests, GitHub Actions workflows, or any YAML-based config file.

★ Pro tip

All valid JSON converts to YAML. Nested objects use indentation, arrays use - prefix. Strings with special characters are automatically quoted.

Who Should Use This Tool?

DevOps Engineers

Convert JSON configuration snippets to YAML for Docker Compose, Kubernetes manifests, and Ansible playbooks.

Developers

Transform JSON API responses or config files to YAML when working with tools that prefer or require YAML format.

Data Engineers

Convert JSON data structures to YAML for use in data pipeline configurations and workflow definitions.

Industry Standard

YAML (YAML Ain't Markup Language) was created by Clark Evans, Ingy döt Net, and Oren Ben-Kiki in 2001. YAML 1.2 (2009) defines JSON as a valid subset of YAML, meaning all JSON is valid YAML 1.2. The YAML specification is maintained at yaml.org. Docker Compose, Kubernetes (CNCF), GitHub Actions, Ansible, Helm, and OpenAPI all adopted YAML as their primary configuration format. The go-yaml and PyYAML libraries are the most widely used YAML parsers; js-yaml is the standard for JavaScript.

Key Use Cases

  • Convert a JSON config snippet from documentation into a YAML file for Docker Compose or Kubernetes.
  • Transform a package.json or tsconfig.json section into YAML for a GitHub Actions workflow.
  • Convert JSON API response examples to YAML for OpenAPI/Swagger specification files.
  • Transform JSON environment configuration to YAML for Ansible or Terraform variable files.
  • Convert JSON schema definitions to YAML format for use in API documentation tools.

JSON to YAML Converter vs Other Formats

How this tool compares to related approaches and methods

Method / FormatBest For
THISThis toolQuick one-off conversion of a JSON snippet to YAML for copy-paste into a config file
js-yaml npm packageNode.js automation scripts, CI tools, and programmatic YAML generation
Python PyYAML yaml.dump()Python scripts and Ansible automation — PyYAML is pre-installed in most environments
yq command-line toolTerminal-based conversion in shell scripts; supports in-place YAML editing and querying

JSON to YAML Converter Rules: How It Works

How JSON Maps to YAML
  • JSON objects {} → YAML key: value pairs, indented with 2 spaces per nesting level.
  • JSON arrays [] → YAML list items prefixed with "- " (dash space).
  • JSON strings → unquoted YAML strings when safe; quoted when the value contains : # & * ? | < > { } [ ] , or starts with special characters.
  • JSON numbers, booleans (true/false), and null → written as-is in YAML without quotes.
  • JSON null → YAML null or ~ (tilde) — both are equivalent.
YAML Gotchas
  • ×YAML is indentation-sensitive — spaces only, no tabs. Editing the output requires keeping indentation consistent.
  • ×YAML special characters (: # &) in string values must be quoted — the converter handles this, but manual edits may introduce errors.
  • ×YAML supports comments (# this is a comment) — JSON does not. Comments can be added to YAML output after conversion.
  • ×YAML anchors and aliases (&anchor / *alias) have no JSON equivalent — they must be added manually if needed.

Where It's Applied

Kubernetes manifestskubectl apply -f deployment.yaml — all K8s resource definitions use YAML; convert JSON examples from docs.
Docker Composedocker-compose.yml uses YAML — convert service configs from JSON documentation snippets.
GitHub Actions.github/workflows/*.yml — workflow definitions, step configs, and matrix strategies are YAML.
OpenAPI / SwaggerAPI specs can be written as YAML (openapi.yaml) — convert JSON examples from Postman exports.
Ansible playbooksAnsible tasks, handlers, and variables are defined in YAML — convert JSON data sources for variable files.
dbt / Airflowdbt schema.yml and Airflow DAG configs use YAML — convert JSON config snippets from documentation.

How to Use JSON to YAML Converter

  1. Paste or type your text into the Input Text box.
  2. The result appears instantly on the right.
  3. Click Copy to copy the output to your clipboard.
  4. Click Clear to reset and process new text.

This Converter vs Manual Methods

Why use this tool instead of doing it by hand?

MethodLimitation
Manually rewriting JSON syntax as YAMLError-prone: easily misses quoting requirements for special characters; impossible for large nested structures
js-yaml in Node.jsRequires Node.js + npm install js-yaml for a one-off task
Python yaml.dump(json.loads(s))PyYAML produces YAML 1.1 output by default — may differ from YAML 1.2 tools (Kubernetes uses YAML 1.2)
yq CLIRequires yq installation; unfamiliar syntax for non-shell users
✓ BESTThis toolNone

Common Mistakes & Pro Tips

  • !Forgetting that YAML is indentation-sensitive — the converter outputs correct indentation, but manually editing the output requires keeping spaces consistent (tabs are not allowed in YAML).
  • !Assuming all JSON is valid YAML — JSON is a subset of YAML 1.2, but YAML has reserved characters (like : and #) that need quoting in string values. Always validate the output in your YAML tool.
  • !Using PyYAML (Python) for Kubernetes or GitHub Actions YAML and getting unexpected type coercions — PyYAML uses YAML 1.1 by default, which has notorious quirks: "NO", "OFF", "YES", "ON" are parsed as booleans (the "Norway problem" — the country code "NO" becomes false). YAML 1.2 fixed this: only "true" and "false" are booleans. For Kubernetes and GitHub Actions, which use YAML 1.2 or a strict subset, use ruamel.yaml (Python YAML 1.2 library) or js-yaml (Node.js YAML 1.2) to avoid YAML 1.1 compatibility surprises.

Frequently Asked Questions

Everything you need to know about JSON to YAML Converter

What is the difference between JSON and YAML?

+

JSON uses curly braces for objects, square brackets for arrays, and requires quoted strings. YAML uses indentation for structure, colons for key-value pairs, dashes for list items, and mostly allows unquoted strings. Both represent the same data. YAML is more human-readable; JSON is more universally supported in APIs.

Which tools use YAML format?

+

YAML is the native format for: Docker Compose (docker-compose.yml), Kubernetes manifests, GitHub Actions workflows (.github/workflows/), Ansible playbooks, Helm charts, Netlify and Vercel configuration, Jekyll and Hugo static site configs, OpenAPI specifications, CircleCI and TravisCI configs, and most modern DevOps tooling.

Is JSON valid YAML?

+

JSON is a subset of YAML 1.2, meaning valid JSON is also valid YAML. However, the reverse is not true — YAML has features that JSON does not (comments, anchors, multi-line strings). For this reason, most YAML parsers can read JSON files directly.

Can I convert YAML back to JSON?

+

Yes — use the JSON Formatter tool, which can parse YAML-style input, or use a dedicated YAML-to-JSON converter. Since JSON and YAML represent the same data structures, conversion in both directions is lossless for simple key-value and array structures.

Why does Kubernetes use YAML instead of JSON?

+

Kubernetes supports both JSON and YAML, but YAML is the standard because it is more human-readable and writable, supports comments (which JSON does not), and requires less punctuation. Kubectl manifests, Helm charts, and Kubernetes documentation all default to YAML for these reasons.

What is the "Norway problem" in YAML 1.1 and how does YAML 1.2 fix it?

+

In YAML 1.1 (the version most libraries implemented through the 2000s–2010s), the following words are parsed as booleans: true/false, yes/no, on/off (and their uppercase variants YES/NO, TRUE/FALSE, ON/OFF). This means the ISO 3166 country code "NO" (Norway) is parsed as false — causing data corruption in any YAML map keyed by country code. Similarly, "OFF" state labels and "ON" switches become booleans. YAML 1.2 (2009) fixed this: only "true" and "false" (lowercase) are booleans; "yes", "no", "on", "off" are plain strings. Kubernetes, GitHub Actions, and most modern tools use YAML 1.2. PyYAML still defaults to YAML 1.1 — use ruamel.yaml for YAML 1.2 compliance in Python.

How do I convert YAML back to JSON?

+

Use a YAML-to-JSON converter or a local command: Node.js: require("js-yaml").load(yamlString) gives a JS object; JSON.stringify(obj, null, 2) gives formatted JSON. Python: import yaml, json; json.dumps(yaml.safe_load(yamlString), indent=2). Command line with yq: echo "name: nginx" | yq -o=json. For a quick paste-and-convert without code, look for a YAML to JSON online converter. Note: YAML features without JSON equivalents (comments, anchors, custom types) are lost in the conversion.

Related Tools

FM
Written by Foysal Mostafa · Developer & Tool Builder · Last reviewed: September 1, 2026
Advertisement