YAML to JSON

YAML to JSON

YAML to JSON converter online free. Convert YAML to pretty JSON format. Copy or download—convert YAML to JSON instantly.

JSON Indent:
📄

YAML Input

JS

JSON Output

YAML JSON

Features

  • Convert YAML to JSON with pretty-printing
  • Handles YAML anchors, aliases, and merge keys
  • Resolves multi-document YAML (<code>---</code>) into a JSON array
  • Syntax error reporting with line numbers
  • Minify or pretty-print the JSON output
  • Copy converted JSON to clipboard

Common Use Cases

  • Convert Kubernetes manifests or Helm values to JSON for API calls
  • Use YAML-authored config in applications that require JSON input
  • Convert OpenAPI YAML specs to JSON for tools that prefer it
  • Process YAML configuration files in languages with better JSON support
  • Migrate YAML-based secrets to JSON for environment variable injection

YAML to JSON Conversion

Converting YAML to JSON parses the YAML into a data structure and serializes it as JSON. Because JSON is a strict subset of YAML, this conversion may encounter YAML features that have no direct JSON equivalent:

  • Comments — YAML comments are discarded (JSON has no comments)
  • Anchors & aliases — Resolved to their referenced values in the JSON output
  • Multi-document — Multiple ----separated documents are output as a JSON array
  • Binary data — YAML binary scalars are base64-encoded as JSON strings

Examples

Valid - YAML input
name: my-app
replicas: 3
enabled: true
Valid - JSON output
{
  "name": "my-app",
  "replicas": 3,
  "enabled": true
}

Frequently Asked Questions

Are YAML comments preserved in JSON output?

No. JSON does not support comments, so all YAML comments are discarded during conversion. If you need to preserve comments for documentation, keep the YAML source file as the canonical version and generate JSON from it as needed.

What happens to YAML anchors in the JSON output?

Anchors (&name) and aliases (*name) are resolved: the alias is replaced by the full value of its anchor target. The JSON output contains the fully expanded data with no references.

Can I convert a multi-document YAML file?

Yes. A YAML file with multiple ----separated documents is converted to a JSON array where each element corresponds to one document. If you need a single object, ensure your YAML file contains only one document.

💡 Tips

  • Use minified JSON output when embedding in environment variables or API payloads.
  • If the YAML uses custom tags (e.g., <code>!!binary</code>), verify the JSON output handles them as expected.
  • For Kubernetes resources, converting to JSON enables you to use <code>kubectl apply -f -</code> with JSON piped from a script.