JSON to YAML Converter

Convert JSON data to YAML format instantly. Supports nested objects, arrays, and custom indentation.

Safe conversion with no data sent to server

Last updated: March 2026

Indent:

What is JSON to YAML Conversion?

YAML (YAML Ain't Markup Language) is a human-friendly data serialization format that uses indentation rather than braces and brackets to represent structure. Converting JSON to YAML is a common developer task because YAML has become the standard configuration format for many modern tools: Docker Compose, Kubernetes manifests, GitHub Actions workflows, Ansible playbooks, CI/CD pipelines (GitLab CI, CircleCI), and many more. These tools require YAML input, but developers often work with or receive data in JSON format.

YAML and JSON are semantically similar -- every JSON document can be represented as YAML, and most YAML documents have JSON equivalents. The key difference is readability. YAML eliminates curly braces, square brackets, and double quotes around keys, replacing them with indentation and simple syntax. For example, a JSON object {"server":{"port":8080,"host":"localhost"}} becomes the much cleaner YAML: server:\n port: 8080\n host: localhost.

This converter handles all JSON data types: objects become YAML mappings, arrays become YAML sequences (using the "-" prefix), strings are preserved with appropriate quoting when needed, and null values are represented as null or ~ in YAML notation. The indentation level is configurable between 2 and 4 spaces to match your project conventions.

How to Use This JSON to YAML Tool

Transform your JSON data into clean YAML with these steps:

  1. Choose your preferred indentation level: 2 spaces (compact, common in YAML conventions) or 4 spaces (more visual separation).
  2. Paste your JSON into the JSON Input field. The input must be valid JSON.
  3. Click "Convert to YAML" to generate the output.
  4. Review the YAML in the output area. It will use clean indentation, dash-prefixed list items, and unquoted keys.
  5. Copy the output or download it as a .yaml file ready for use in your project.

Tip: If you are generating Kubernetes manifests or Docker Compose files, use 2-space indentation as this is the community standard for those ecosystems. Validate the resulting YAML with your target tool to ensure compatibility.

Common Use Cases

  • Kubernetes configuration: Convert JSON resource definitions (Pods, Services, Deployments) into YAML manifests for kubectl apply.
  • Docker Compose files: Transform JSON service definitions into docker-compose.yml format for container orchestration.
  • CI/CD pipelines: Generate GitHub Actions workflow files, GitLab CI configuration, or CircleCI config from JSON data structures.
  • Ansible playbooks: Convert JSON task definitions into YAML playbooks for infrastructure automation.
  • Application configuration: Create YAML config files for frameworks like Spring Boot (application.yml), Rails (database.yml), or Hugo (config.yaml).
  • OpenAPI/Swagger specs: Convert JSON API specifications to YAML format, which is often preferred for readability in API documentation.
  • Infrastructure as Code: Generate CloudFormation templates or Terraform variable files in YAML from JSON data sources.

FAQ

Are JSON and YAML fully interchangeable?

Nearly. Every valid JSON document can be converted to YAML because YAML is a superset of JSON. However, YAML has features that JSON lacks, such as comments, anchors/aliases, and multi-line strings. When converting from JSON to YAML, all data is preserved. Converting back from YAML to JSON may lose comments and YAML-specific constructs.

How are JSON null values handled in YAML?

JSON null values are converted to YAML null, which can also be represented as ~ or simply an empty value. Most YAML parsers interpret all three forms identically. This tool uses the explicit "null" keyword for clarity.

When should I use 2-space vs. 4-space indentation?

Two-space indentation is the community standard for Kubernetes, Docker Compose, and most DevOps tools. Four-space indentation may be preferred for application configs or when deeper nesting makes 2-space indentation hard to read. Consistency within a project matters more than the specific choice.

Does the converter handle deeply nested JSON?

Yes. The tool recursively processes all levels of nesting, converting nested JSON objects to indented YAML mappings and nested arrays to properly indented YAML sequences. Even complex structures with multiple levels of nesting are accurately represented in the output.