JSON to YAML Converter

Convert JSON to YAML format instantly. Clean output, handles nested structures.

Input
Output

How to Convert JSON to YAML

  1. Paste your JSON into the input panel on the left. Any valid JSON is accepted — objects, arrays, deeply nested structures, and even single values.
  2. Click “Convert to YAML” to transform the JSON into clean, properly indented YAML in the output panel.
  3. Review the output — objects become indented key-value pairs, arrays use the dash (-) prefix, and strings are quoted only when necessary for YAML compatibility.
  4. Copy the result using the copy button on the output panel. The YAML is ready to paste into your configuration file, CI/CD pipeline, or documentation.

What is JSON to YAML Conversion?

JSON and YAML are both data serialization formats, but they serve different purposes. JSON (JavaScript Object Notation) is the dominant format for APIs, data exchange, and programmatic configuration. YAML (YAML Ain’t Markup Language) is preferred for human-edited configuration files because its indentation-based syntax is easier to read and write than JSON’s braces and brackets.

This converter takes valid JSON input and produces equivalent YAML output. The mapping is straightforward: JSON objects become YAML mappings, JSON arrays become YAML sequences with dash prefixes, and primitive values (strings, numbers, booleans, null) convert directly. If you need to first clean up your JSON, use the JSON Formatter before converting.

Examples

1. Application config file conversion

Convert a JSON config to YAML for easier editing:

{
  "app": {
    "name": "my-service",
    "port": 3000,
    "debug": false
  },
  "database": {
    "host": "localhost",
    "port": 5432,
    "name": "mydb"
  }
}

YAML output:

app:
  name: my-service
  port: 3000
  debug: false
database:
  host: localhost
  port: 5432
  name: mydb

2. Kubernetes manifest

Kubernetes resources are typically written in YAML. Convert a JSON template to YAML for deployment:

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

YAML output:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
  labels:
    app: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web

3. Docker Compose service definition

Docker Compose files use YAML. Convert a JSON service definition:

{
  "services": {
    "web": {
      "image": "nginx:alpine",
      "ports": ["80:80", "443:443"],
      "volumes": ["./html:/usr/share/nginx/html"],
      "environment": {
        "NGINX_HOST": "example.com",
        "NGINX_PORT": "80"
      }
    }
  }
}

YAML output:

services:
  web:
    image: nginx:alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./html:/usr/share/nginx/html
    environment:
      NGINX_HOST: example.com
      NGINX_PORT: "80"

4. CI/CD pipeline configuration

GitHub Actions, GitLab CI, and other CI/CD systems use YAML. Convert JSON workflow definitions to YAML for your pipeline configuration files.

Common Use Cases

  • Kubernetes manifests: Convert JSON resource definitions to YAML for kubectl apply and Helm charts.
  • Docker Compose files: Generate docker-compose.yml from JSON service definitions.
  • CI/CD pipelines: Create GitHub Actions workflows, GitLab CI configs, or CircleCI configs from JSON templates.
  • Ansible playbooks: Convert JSON task definitions to YAML playbook format.
  • Configuration management: Switch from JSON to YAML config files for better readability and comment support.
  • API documentation: Convert JSON examples to YAML for OpenAPI/Swagger spec files.
  • Data transformation chains: Use with the CSV to JSON converter to go from CSV data to YAML config format in two steps.
  • Infrastructure as Code: Convert JSON CloudFormation or Terraform variable files to YAML equivalents.

Frequently Asked Questions

Does the converter preserve comments?

JSON does not support comments, so there are no comments to preserve during conversion. If you need comments in your YAML output, add them manually after conversion. YAML supports both inline comments (# after a value) and full-line comments.

What YAML version does it output?

The converter produces YAML 1.2 compatible output, which is the current standard and is compatible with most modern YAML parsers including those used by Kubernetes, Docker Compose, GitHub Actions, and Ansible.

How does it handle anchors and aliases?

The converter does not generate YAML anchors (&) or aliases (*) because JSON has no equivalent concept. The output is a straightforward mapping of JSON structures to YAML. If you need anchors for deduplication, add them manually after conversion.

Can it handle large files?

Yes. All processing runs in your browser. Most modern devices handle JSON files up to 50 MB. The YAML output is typically slightly larger because YAML uses indentation instead of braces, but the difference is minimal.

How are multi-line strings handled?

Strings containing newline characters are converted to YAML block scalars using the literal style (|), which preserves line breaks exactly as they appear. This produces clean output for descriptions, SQL queries, or embedded scripts.

Can I convert YAML back to JSON?

This tool converts JSON to YAML. For the reverse direction, you can use a YAML parser to load the YAML and serialize it as JSON. Use the JSON Formatter to clean up the output, or explore the result in the JSON Viewer.

Privacy & How It Works

This JSON to YAML converter processes everything locally in your browser. When you click Convert, the tool parses your JSON with JSON.parse() and walks the resulting object tree to build YAML output using indentation-based formatting rules. No data is sent to any server, no cookies are set, and nothing is stored after you close the tab. The conversion handles all JSON data types — objects, arrays, strings, numbers, booleans, and null — mapping each to its YAML equivalent. You can verify the client-side processing by checking your browser’s Network tab during conversion: zero requests are made. This makes the tool safe for converting sensitive configuration files, credentials, and proprietary infrastructure definitions.