YAML ↔ JSON Converter
Indent
YAMLInput
28 lines359 B
JSONOutput
{
  "server": {
    "host": "api.example.com",
    "port": 8080,
    "tls": true
  },
  "database": {
    "engine": "postgresql",
    "host": "db.example.com",
    "port": 5432,
    "name": "appdb",
    "pool": {
      "min": 2,
      "max": 10
    }
  },
  "features": [
    {
      "name": "auth",
      "enabled": true,
      "roles": [
        "admin",
        "user"
      ]
    },
    {
      "name": "analytics",
      "enabled": false
    }
  ],
  "metadata": {
    "version": "2.1.0",
    "tags": [
      "production",
      "backend"
    ]
  }
}
38 lines555 B21 keys

YAML to JSON Converter Free — JSON to YAML Online, Kubernetes & Docker Config

Updated May 14, 2026
Share & Support

What's included

Features

Bidirectional conversion: YAML → JSON and JSON → YAML with one click
Auto-detect input format — detects JSON by leading { or [, falls back to YAML
Syntax-highlighted output: JSON keys, strings, numbers, booleans in distinct colors
YAML syntax highlighting: keys, string values, numbers, booleans, comments, anchors
Indent control: 2-space (JavaScript standard) or 4-space (Python/Java convention)
Sort keys — recursively sorts all object keys at every nesting level
Copy output to clipboard — single click, confirms with ✓ feedback
Download output as .json or .yaml file to disk — if the JSON output is a dataset, paste it into the JSON Dashboard Generator to visualize it as charts and filters instantly
Swap button — instantly use output as new input for round-trip conversions
Line numbers and size stats (bytes, lines, total key count) for both panels
Built on js-yaml — full YAML 1.2 support: anchors, aliases, multi-line blocks
100% client-side — nothing sent to any server, works offline

About this tool

Convert YAML to JSON or JSON to YAML Instantly — No Install, No Sign-Up

You have a Kubernetes manifest or Docker Compose file in YAML and you need to inspect it as JSON, or run it through a tool that only accepts JSON. Or you have a JSON response from an API that you want to read as YAML because it's cleaner to scan. Paste it here and get the converted output instantly.

YAML and JSON describe the same kinds of data structures — strings, numbers, booleans, arrays, and objects — but in very different syntax. YAML uses indentation and colons, making it human-readable for config files. JSON uses braces and quotes, making it the universal format for APIs. This tool bridges them in both directions.

YAML → JSON is the most common direction. API testing tools like Postman and Insomnia need JSON request bodies. Some tooling accepts JSON config but only documents YAML examples. The converter handles all YAML 1.2 types: strings, numbers, booleans (including yes/no), null values (~), multi-line strings, dates, and anchors & aliases.

JSON → YAML is equally useful. Deeply nested JSON is hard to read. Converting to YAML makes the structure immediately scannable. It's also the right workflow when drafting Kubernetes configs or Helm chart values — write the JSON structure in your editor with bracket matching, then convert to YAML for the final file.

One important note: YAML comments are lost when converting to JSON. JSON has no comment syntax — there's no equivalent representation. If your YAML has comments you need to preserve, keep the YAML file and only use JSON output for data interchange.

Under the hood, YAML parsing uses js-yaml's DEFAULT_SCHEMA, so booleans like yes/no/on/off, null written as ~, and both quoted and block (|/>) string styles all resolve to the correct JavaScript types before JSON.stringify runs. Dumping uses noRefs: true and lineWidth: -1, so repeated object references are fully expanded into separate YAML nodes instead of &anchor/*alias syntax, and long scalars are written on one line rather than wrapped — output that matches what most YAML linters expect.

The optional Sort keys pass walks the parsed object graph recursively, alphabetizing keys at every depth before serialization, which is what makes two structurally similar configs diff cleanly in git. Parse failures are translated into readable messages, with YAML errors reporting the exact line number extracted from js-yaml's exception text so you know where the indentation or syntax broke.

Everything runs in your browser using js-yaml. No server, no sign-up, works offline.

Step by step

How to Use

  1. 1
    Paste YAML or JSON into the input panelPaste your YAML or JSON into the left input panel. The Auto direction setting detects the format automatically — anything starting with { or [ is treated as JSON, everything else as YAML. Or click YAML → JSON / JSON → YAML from the direction toggle to lock the conversion direction.
  2. 2
    Review the converted outputThe right output panel shows the converted result with full syntax highlighting immediately — no button press needed. JSON output highlights keys, strings, numbers, and booleans in distinct colors. YAML output highlights keys, values, comments, anchors, and list markers. Line numbers and size stats (bytes, lines, total keys) appear in the footer of both panels.
  3. 3
    Choose indent sizeClick 2 or 4 in the header controls to set the indentation width. 2 spaces is the JavaScript/Node.js convention and produces more compact output. 4 spaces is common in Python and Java projects. The setting applies to both JSON pretty-printing and YAML block indentation.
  4. 4
    Sort keys alphabeticallyEnable Sort keys to recursively alphabetize all object keys at every nesting level. This is useful before committing config files to version control — sorted output produces cleaner diffs — and when comparing two similar configs where key order may differ.
  5. 5
    Swap for round-trip testingClick the ↔ swap arrows button between the two panels to copy the current output into the input and re-convert in the opposite direction. This lets you verify a round-trip: convert YAML → JSON, swap, convert JSON → YAML, and compare with the original to confirm nothing was lost.
  6. 6
    Copy or download the outputClick Copy in the output panel to copy to clipboard — a ✓ confirmation appears briefly. Click Download to save the file as .json or .yaml depending on the output format. Load sample data using YAML sample or JSON sample buttons in the input panel.

Real-world uses

Common Use Cases

🐳
Convert a Kubernetes manifest or Docker Compose file to JSON
Paste a Kubernetes manifest or Docker Compose YAML to get the equivalent JSON for programmatic inspection, validation tools, or API clients that only accept JSON. Supports anchors, aliases, and all YAML 1.2 features.
🔌
Get JSON for an API test from a YAML config
Postman, Insomnia, and most HTTP clients need JSON request bodies. Write the request structure in YAML (cleaner to edit), convert here, and paste the JSON directly into your API testing tool — or straight into our API request tester.
🐙
Inspect or transform a GitHub Actions or CI/CD workflow file
Convert GitHub Actions, Travis CI, CircleCI, or Ansible playbook YAML to JSON for programmatic inspection or manipulation with scripts, then convert the modified JSON back to YAML for the final file.
📋
Convert an OpenAPI spec between YAML and JSON for tooling compatibility
OpenAPI specs exist in both formats. Some validators and code generators only accept JSON; some editors prefer YAML. Paste your spec and get the other format instantly — lossless in both directions.
🔎
Make a deeply nested JSON response easier to read
API responses in JSON are hard to scan when deeply nested. Convert to YAML to get a clean, indented structure without braces and quotes. Sort keys to make the hierarchy even easier to navigate. If the response is a data array, paste the JSON directly into the JSON Dashboard Generator to get charts and a sortable table without any manual work.
🗂️
Author a Helm chart or Ansible config starting from JSON
Draft a complex data structure in JSON where your editor enforces bracket matching and syntax validation, then convert to YAML for the final Helm values file, Ansible vars, or Terraform tfvars.

Got questions?

Frequently Asked Questions

YAML uses indentation and is designed for human readability — it is the format of Docker Compose, Kubernetes, Ansible, and GitHub Actions. JSON uses braces and quotes and is the universal API data format. YAML is a superset of JSON, so every JSON document is valid YAML, but YAML has additional features (comments, anchors, multi-line strings) that JSON does not.

Paste your YAML into the left panel — the tool auto-detects it and shows converted JSON in the right panel. Click Copy or Download to get the output.

No. JSON has no comment syntax, so YAML comments are dropped during conversion. This is a limitation of the JSON format itself. Keep your original YAML if you need the comments.

Yes. YAML anchors (&name) and aliases (*name) are fully supported — they are resolved and inlined in the JSON output. YAML merge keys (<<) are also handled.

It recursively sorts all object keys alphabetically at every nesting level. Useful for normalizing configs for version control diffs and for making large files easier to scan.

It copies the current output into the input panel for round-trip conversion. Use it to convert YAML → JSON, then swap and convert the JSON back to YAML to verify nothing was lost.

Yes. JSON → YAML is always lossless because JSON is a strict subset of YAML — every JSON type maps exactly to a YAML type. YAML → JSON can lose comments and resolves anchors/aliases.

Yes — conversion runs entirely in your browser and is not limited by server-side timeouts. Performance depends on your browser. Very large files (several MB) may take a moment.

Free, no sign-up, and 100% client-side. Your YAML and JSON data never leaves your browser — nothing is sent to any server.

2 produces 2-space indented output (JavaScript/Node.js convention). 4 produces 4-space output (Python/Java convention). Choose based on your project's code style.