Skip to content

YAML to JSON

Convert YAML to JSON instantly with validation and formatted output.

Part of Dev Utils · Built by Sandeep Upadhyay

  • YAML to JSON conversion
  • Syntax validation
  • Formatted JSON output

When to use YAML to JSON

  • Converting Kubernetes manifests to JSON: Some tooling and API clients require Kubernetes resource definitions as JSON. Convert from the YAML you write to JSON for programmatic consumption.
  • Validating GitHub Actions workflow syntax: Parse a .github/workflows/*.yml file through the YAML validator to catch indentation errors before pushing and triggering a failed CI run.
  • Preparing API test fixtures: Write test data as readable YAML and convert to JSON before pasting into a REST client or embedding in a test file.
  • Reading dense JSON configuration: Convert a minified or deeply nested JSON configuration file to YAML for easier human reading without changing the underlying data.

How YAML and JSON map to each other and where they differ

The YAML to JSON converter parses YAML input using a spec-compliant parser that implements YAML 1.2, the current specification published by the YAML Language Development Team. YAML 1.2 aligns YAML's core data model more closely with JSON - any valid JSON document is also valid YAML 1.2, because YAML is a strict superset of JSON at the syntax level. The parsed YAML is converted to a JavaScript object and then re-serialised as JSON using JSON.stringify() with two-space indentation.

YAML's human-friendly syntax - indentation-based nesting, unquoted strings, multi-line block scalars, and comment support - makes it the preferred format for configuration files (GitHub Actions workflows, Kubernetes manifests, Docker Compose files, Ansible playbooks). JSON's explicit structure - quoted keys, comma separators, brackets, and braces - makes it the preferred format for API payloads and data interchange. The converter handles the key differences: YAML null and ~ both become JSON null; YAML true/false/yes/no/on/off all become JSON true or false; YAML multi-line block scalars (using | or >) become single JSON string values with embedded newlines.

The reverse direction (JSON to YAML) is also supported. JSON structures convert cleanly to YAML because YAML can represent any JSON value type, but the output uses YAML's more readable block-style syntax rather than JSON's flow style. This is useful when taking a JSON config you have received and converting it to YAML for a tool that expects YAML input.

Try YAML to JSON

Interactive YAML to JSON - coming soon