YAML ⇄ JSON Converter

Convert YAML to JSON or JSON back to YAML for CI pipelines, Docker, Kubernetes and app configs.

Back to all tools on ToolForge

More in JSON & API

YAML



JSON



Status

Ready.

About YAML to JSON Converter

This YAML to JSON converter helps you switch between YAML and JSON formats for configuration files, pipeline definitions, and structured data. The conversion uses the js-yaml library (v4.1.0) for YAML 1.2 specification compliance.

It is useful for Kubernetes manifests, Docker Compose files, CI/CD pipeline configs (GitHub Actions, GitLab CI), and application configuration files where you need to convert between human-readable YAML and machine-friendly JSON.

YAML vs JSON Comparison

Feature YAML JSON
Syntax style Indentation-based (whitespace significant) Brace-based (explicit delimiters)
File size More compact (no braces/quotes needed) More verbose (explicit structure)
Comments Supported (# comment) Not supported
Quotes Optional for simple strings Required for all string keys/values
Data types Strings, numbers, bools, dates, null Strings, numbers, bools, null, arrays, objects
Parse speed Slower (complex spec) Faster (simple spec)

YAML Syntax Basics

# Key-value pairs (colon + space)
name: Tom
age: 20

# Lists (dash + space)
hobbies:
  - reading
  - coding

# Nested structures (2-space indent)
address:
  city: NYC
  zip: 10001

# Multi-line strings
description: |
  This is a literal block
  that preserves line breaks

# Anchors and aliases
defaults: &defaults
  adapter: postgres

production:
  <<: *defaults
  database: prod_db

JSON Syntax Basics

{
  "name": "Tom",
  "age": 20,
  "hobbies": ["reading", "coding"],
  "address": {
    "city": "NYC",
    "zip": 10001
  },
  "active": true,
  "metadata": null
}

Common Use Cases

Domain Format Preference Example
Kubernetes YAML Deployments, Services, ConfigMaps
Docker YAML docker-compose.yml
CI/CD YAML .github/workflows, .gitlab-ci.yml
REST APIs JSON Request/response bodies
Node.js configs JSON package.json, tsconfig.json

Conversion Considerations

Common Syntax Errors

YAML errors:

JSON errors:

Frequently Asked Questions

What is the difference between YAML and JSON?
YAML (YAML Ain't Markup Language) uses indentation and line breaks for structure, making it more human-readable. JSON (JavaScript Object Notation) uses braces and brackets with explicit delimiters. YAML supports comments and anchors; JSON does not. JSON is universally supported and faster to parse; YAML is preferred for configuration files.
Why convert between YAML and JSON?
Different tools prefer different formats: Kubernetes and Docker use YAML, while many APIs require JSON. Converting lets you edit configs in a readable YAML format, then export to JSON for API consumption, or vice versa—import JSON API responses as YAML for easier manual editing.
Does the converter preserve data types?
Yes, both formats support strings, numbers, booleans, arrays, and objects. YAML has additional types like dates and multi-line strings. When converting YAML→JSON, dates become strings. When converting JSON→YAML, strings may be quoted or unquoted based on content.
What YAML features are supported?
This tool uses js-yaml v4.1.0 which supports YAML 1.2 specification: scalars, sequences, mappings, anchors and aliases (&anchor/*alias), multi-line strings (| and >), and type tags. Advanced features like custom tags require server-side processing.
What are common YAML syntax errors?
Common errors: inconsistent indentation (use spaces, not tabs), missing colon after key, incorrect list syntax, unquoted special characters in strings, and tab characters (YAML requires spaces). The converter will show parse error details to help identify issues.
What are common JSON syntax errors?
Common errors: trailing commas in arrays/objects, unquoted keys (must use double quotes), single quotes instead of double quotes, comments (JSON doesn't support comments), and missing commas between elements. Use a JSON validator to check syntax.