Ttooleras
🔀

JSON to YAML Converter

Converters

Convert JSON to YAML or YAML to JSON — preserves structure, nested objects. Free, private — all processing in your browser.

Advertisement

The JSON to YAML Converter translates data between JSON (JavaScript Object Notation) and YAML (YAML Ain't Markup Language) — the two most popular structured data formats in modern development. Paste JSON from an API response or config file and get clean, properly-indented YAML output. Or reverse: paste YAML from a Kubernetes manifest, GitHub Actions workflow, Docker Compose file, or Ansible playbook and get the equivalent JSON. Handles any depth of nesting, arrays, boolean/null values, multi-line strings, and special YAML features like anchors and references.

JSON is the dominant format for APIs (lightweight, easy to parse). YAML is the preferred format for configuration files (human-readable, supports comments, less syntactic noise). Many modern tools use YAML configs that reference structured data originally in JSON: Kubernetes manifests, Helm charts, Docker Compose, GitHub Actions workflows, CircleCI, GitLab CI, Ansible playbooks, Jekyll/Hugo front matter, OpenAPI/Swagger specs. Being able to convert cleanly between the two is essential. This tool does it instantly in your browser — configs stay private.

JSON to YAML Converter — key features

Bidirectional conversion

JSON → YAML and YAML → JSON with one click. Toggle between directions as needed.

Preserves data types

Booleans, nulls, numbers, strings, arrays, objects — all round-trip correctly between formats.

Configurable indentation

2 spaces (common), 4 spaces, or tab. Match your project's style guide.

Block or flow style

Block style (indented, multi-line) is the YAML default. Flow style (compact, JSON-like) for inline data.

Syntax validation

Invalid JSON or YAML is detected with a clear error message and line number.

Quote style options

Choose double quotes, single quotes, or unquoted when safe. Match your team's YAML conventions.

Handle large files

Multi-megabyte configs process without issue. Kubernetes manifests, OpenAPI specs, all work.

100% client-side

Your configs never leave the browser. Safe for production configs, credentials in manifests, internal data.

How to use the JSON to YAML Converter

  1. 1

    Paste your input

    Drop in JSON or YAML. Tool auto-detects the format.

  2. 2

    Choose direction

    JSON → YAML or YAML → JSON. Switch with a single click.

  3. 3

    Set indentation

    2 or 4 spaces typically. Match your project's style.

  4. 4

    Pick quote style (YAML output)

    Double quotes universal, single quotes for strings with special characters, unquoted when safe.

  5. 5

    Copy or download

    Copy output to clipboard or download as .json, .yaml, or .yml file.

Common use cases for the JSON to YAML Converter

DevOps and infrastructure

  • Kubernetes manifests: K8s requires YAML but many tools generate JSON. Convert API responses from `kubectl ... -o json` to YAML for editing.
  • Docker Compose: Convert a compose.yaml to JSON for scripting, or generate YAML from JSON config templates.
  • Ansible playbooks: Convert configuration data from JSON (pulled from APIs) to YAML for Ansible playbooks.
  • Terraform converts: While Terraform uses HCL, some workflows require YAML/JSON conversion for data inputs.

CI/CD configuration

  • GitHub Actions workflows: Workflows are YAML. Convert existing JSON pipelines to YAML when migrating.
  • GitLab CI: Similar to GitHub Actions — YAML configs. Convert for migration or tooling.
  • CircleCI config: YAML-based. Convert from other formats for migration.
  • Azure Pipelines: YAML config. Convert for portability.

API and documentation

  • OpenAPI / Swagger specs: Both JSON and YAML formats supported. Convert between them depending on tool preferences.
  • GraphQL schema translations: Some GraphQL tools generate schema in JSON; convert to YAML for readability.
  • Jekyll / Hugo front matter: Static site generators use YAML front matter. Convert from JSON APIs for content imports.

Config management

  • Migrate configs between formats: Tools often support both; convert for your preferred format.
  • Readability: YAML is more readable than JSON for complex configs — convert when editing.
  • Version control readability: YAML diffs are cleaner than JSON diffs — convert before committing config files.

JSON to YAML Converter — examples

Simple JSON to YAML

Basic object conversion.

Input
{
  "name": "Jane Doe",
  "age": 36,
  "admin": true
}
Output
name: Jane Doe
age: 36
admin: true

Nested structure

Deeply nested object with arrays.

Input
{
  "user": {
    "name": "Jane",
    "roles": ["admin", "editor"],
    "meta": {
      "created": "2026-05-05"
    }
  }
}
Output
user:
  name: Jane
  roles:
    - admin
    - editor
  meta:
    created: "2026-05-05"

Kubernetes deployment (JSON to YAML)

Common DevOps use case.

Input
{
  "apiVersion": "apps/v1",
  "kind": "Deployment",
  "metadata": {
    "name": "my-app"
  },
  "spec": {
    "replicas": 3,
    "selector": {
      "matchLabels": {
        "app": "my-app"
      }
    }
  }
}
Output
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app

YAML to JSON

Reverse direction — for API consumption.

Input
version: '3.8'
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
Output
{
  "version": "3.8",
  "services": {
    "web": {
      "image": "nginx:latest",
      "ports": ["80:80"]
    }
  }
}

Array of objects

List of structured items.

Input
[
  {"name": "Alice", "age": 30},
  {"name": "Bob", "age": 25}
]
Output
- name: Alice
  age: 30
- name: Bob
  age: 25

Null and boolean

Type preservation.

Input
{
  "enabled": true,
  "disabled": false,
  "missing": null
}
Output
enabled: true
disabled: false
missing: null

Technical details

JSON and YAML both represent structured data — objects (maps), arrays (lists), and scalar values (strings, numbers, booleans, null) — but with different syntax optimized for different use cases.

JSON (RFC 8259, 2017):

- Strict syntax, no comments.
- Quotes required around all keys and string values.
- Commas between elements, required.
- Compact and unambiguous; ideal for machine-to-machine.

YAML (yaml.org spec 1.2.2, 2021):

- Indentation-based (like Python).
- Quotes optional for simple strings.
- Supports comments (#), anchors (&name), aliases (*name), and multi-line strings.
- Human-readable and expressive; ideal for config files.

Conversion rules:

- JSON object { "a": 1 } → YAML a: 1
- JSON array [1, 2, 3] → YAML - 1\\n- 2\\n- 3
- JSON string "hello" → YAML hello (or "hello" if ambiguous)
- JSON boolean true/false → YAML true/false
- JSON null → YAML null or ~ or empty
- JSON number 3.14 → YAML 3.14
- Nested JSON objects → YAML nested indentation

YAML quirks that don't round-trip cleanly:

- The Norway problem: YAML 1.1 parses NO, no, off, false as boolean false. Country code for Norway (NO) becomes false! YAML 1.2 fixed this, but many parsers still use 1.1 semantics.
- Unquoted numbers: 3:30 is interpreted as time (3 hours, 30 minutes). 08 and 09 are invalid octal; 0.0 is 0. Version numbers like 1.0 become floats.
- Multi-line strings: Multiple syntaxes (|, >, "...", '...') with subtle differences.
- Anchors and aliases: &anchor_name and *anchor_name have no JSON equivalent — conversion flattens them.

Recommended defaults:

- Always use YAML 1.2 compatible tooling.
- Use double quotes around strings that look like booleans, numbers, dates, or special values.
- Use version: "1.0" not version: 1.0.
- Avoid anchors and references when converting to JSON (they'll be expanded).

Block vs flow style:

YAML supports two styles:

Block (default, human-readable):
``yaml
user:
name: Jane Doe
roles:
- admin
- editor
``

Flow (JSON-like, compact):
``yaml
user: {name: "Jane Doe", roles: ["admin", "editor"]}
``

Flow style is essentially JSON with YAML quirks. Block style is preferred for config files.

JSON vs YAML file sizes:

- Same data: YAML typically ~10-20% smaller (no quotes, no braces, fewer commas).
- With comments: YAML supports them, JSON doesn't. If you need comments, YAML wins.

Common problems and solutions

The Norway problem

YAML 1.1 parses `NO`, `no`, `off`, `false` as boolean. Country code for Norway (`NO`) becomes `false`! Fix: quote the string (`country: "NO"`) or upgrade your YAML parser to 1.2 (which fixed this).

Unquoted version numbers

`version: 1.0` is parsed as float `1.0` — not the string `"1.0"`. Always quote version strings: `version: "1.0"` to avoid `1` appearing in output instead of `1.0`.

Date parsing ambiguity

YAML 1.1 tries to parse date-like strings. `2026-05-05` becomes a Date object. Quote as `"2026-05-05"` if you want a string. YAML 1.2 requires explicit `!!timestamp` tags.

Losing comments during round-trip

Comments exist in YAML but not in JSON. Converting YAML → JSON → YAML loses all comments. If you need to preserve, edit YAML directly.

Anchor/alias flattening

YAML anchors (`&name`) and aliases (`*name`) don't have JSON equivalents. Conversion to JSON expands all references, duplicating data. Converting back to YAML creates expanded form without anchors.

Multi-line string handling

YAML has multiple multi-line string forms (`|`, `>`, with `+`/`-`/`0` indicators). JSON has no native multi-line — requires `\n`. Round-tripping may change the exact string form.

Octal number confusion

YAML 1.1: `08` and `09` are invalid (not valid octal). `010` is 8 (octal). YAML 1.2 uses `0o` prefix: `0o10` is 8. Quote numbers if they might be misinterpreted.

Trailing whitespace matters

YAML uses indentation for structure. A trailing space or mixed tabs/spaces breaks parsing. Most editors highlight invalid indentation.

JSON to YAML Converter — comparisons and alternatives

JSON vs YAML: JSON is strict, compact, machine-first (ideal for APIs). YAML is readable, human-first (ideal for configs). Both represent the same data structures. API responses use JSON. Configuration files use YAML.

JSON vs TOML: TOML (used by Cargo, poetry, Hugo) is another config format — simpler than YAML, more explicit, no significant whitespace. Good for simple configs. Less widespread than YAML.

YAML 1.1 vs YAML 1.2: 1.2 fixes the Norway problem (booleans require true/false, not yes/no), removes octal ambiguity, and modernizes the spec. 1.1 is still common in tooling. Check which your parser uses.

YAML vs JSON5: JSON5 is JSON with YAML-like conveniences (comments, trailing commas, unquoted keys). Simpler than YAML but less widespread.

YAML vs XML: XML is older, more verbose, and used for enterprise (SOAP, RSS, Office docs). YAML is a modern, lighter alternative. Most new projects use YAML or JSON, not XML.

YAML vs HCL: HCL (Terraform's language) is a config language designed specifically for infrastructure-as-code. More expressive than YAML for complex logic. YAML is simpler and more widespread.

Frequently asked questions about the JSON to YAML Converter

What is the difference between JSON and YAML?

JSON is strict, machine-oriented, requires quotes around all keys and strings, uses commas and braces/brackets. YAML is human-oriented, uses indentation (like Python), allows unquoted strings, supports comments, supports multi-line strings. Same data structures, different syntax. JSON is typical for APIs; YAML is typical for configs.

Is my YAML/JSON safe to convert here?

Yes. Conversion happens entirely in your browser. Config files with sensitive data (passwords, API keys, infrastructure details) never leave your device. No server interaction, no logging. Open DevTools Network tab to verify zero outbound requests.

Can I convert Kubernetes YAML to JSON?

Yes. Paste any Kubernetes manifest (Deployment, Service, ConfigMap, etc.) and it converts to JSON. Works in both directions for tools that prefer one format over the other.

Do anchors and references work?

Partially. When converting YAML → JSON, anchors (&name) are expanded — references are replaced with their values. This produces larger but equivalent JSON. When converting JSON → YAML, the tool produces expanded form (no anchors). If you need to preserve anchors, edit YAML directly.

What about comments?

Comments exist in YAML (# comment) but not in JSON. Converting YAML → JSON loses all comments. Converting JSON → YAML doesn't add comments. For documentation-heavy configs, edit YAML directly.

Why does my country code get converted to boolean?

This is the famous "Norway problem" — YAML 1.1 parses NO, no, false, off as boolean. Country code NO (Norway) becomes false. Fix: quote the value: country: "NO". YAML 1.2 removes this ambiguity.

Should I use YAML or JSON for my project?

APIs, data transfer, programmatic generation: JSON. Strict, fast, universal. Configuration files, human-edited: YAML. Readable, supports comments, less syntactic noise. Most projects use both — JSON for APIs, YAML for configs.

What indentation should YAML use?

2 spaces is the most common convention (used by Kubernetes, Docker Compose, GitHub Actions). 4 spaces also valid. Never mix tabs and spaces or inconsistent indentation — YAML parsers reject it.

How do I handle multi-line strings?

YAML has 4 styles: | (literal, preserves newlines), > (folded, newlines become spaces), "..." (double-quoted, escape sequences), '...' (single-quoted, literal). | is common for code blocks. JSON has no native multi-line — uses \n escapes.

Can I convert YAML with custom tags?

Most custom YAML tags (!MyTag) are parser-specific and don't round-trip to JSON. Standard tags (!!str, !!int, !!timestamp) are handled automatically. For custom schemas, you may need format-specific tools.

Additional resources

Advertisement

Related tools

All Converters

Learn more

Explore more tools

200+ free tools that run in your browser.

Browse all tools →