Convertee/Guide

How to Convert YAML to JSON: Complete Guide

Last updated: 2026-04-14

YAML has become the configuration language of choice for Kubernetes manifests, Docker Compose files, GitHub Actions workflows, and Ansible playbooks. Yet most programming languages and APIs consume JSON natively. When you need to validate a YAML config programmatically, feed it into a REST endpoint, or store it in a document database, converting to JSON is the pragmatic move.

Step-by-Step: Convert YAML to JSON with Convertee

  1. Open Convertee and choose YAML as source and JSON as target.
  2. Paste your YAML content into the input panel, or drag-and-drop a .yaml / .yml file.
  3. Adjust the JSON indent level if needed (2 spaces, 4 spaces, tabs, or minified).
  4. Press Convert (Cmd+Enter).
  5. Copy the JSON output or download it as a .json file.

Your YAML is parsed and converted entirely in the browser — no data leaves your machine.

Understanding the Formats

YAML

YAML (YAML 1.2) is a human-friendly data serialization language. It uses indentation to denote structure (no curly braces or brackets), supports comments with #, anchors and aliases for reuse, and multi-line strings with block scalars (| and >). YAML is a strict superset of JSON — every valid JSON document is also valid YAML.

JSON

JSON (RFC 8259) trades YAML's human readability for strict, unambiguous machine parsing. No comments, no anchors, no multi-line strings — but universal support across every programming language and tool. This makes JSON the safer choice for data interchange and API payloads.

Before / After Example

Input YAML:

server:
  host: 0.0.0.0
  port: 8080
  tls:
    enabled: true
    cert: /etc/ssl/cert.pem

database:
  driver: postgres
  connection:
    host: db.example.com
    port: 5432
    name: myapp

Output JSON:

{
  "server": {
    "host": "0.0.0.0",
    "port": 8080,
    "tls": {
      "enabled": true,
      "cert": "/etc/ssl/cert.pem"
    }
  },
  "database": {
    "driver": "postgres",
    "connection": {
      "host": "db.example.com",
      "port": 5432,
      "name": "myapp"
    }
  }
}

Common Use Cases

Options and Configuration

OptionDefaultWhat It Does
JSON indent2 spacesSets the indentation of the output. Choose 2 or 4 spaces, tabs, or minified.
Resolve anchorsOnYAML anchors (&name) and aliases (*name) are resolved into their full values in the JSON output.
Multi-documentFirst onlyIf the YAML contains multiple documents (separated by ---), this controls whether to convert only the first document or wrap all documents in a JSON array.

Frequently Asked Questions

Does Convertee support YAML anchors and aliases?
Yes. YAML anchors (&name) and aliases (*name) are resolved automatically during conversion. The JSON output contains the fully expanded values.
How are YAML comments handled?
JSON does not support comments, so YAML comments (lines starting with #) are stripped during conversion. The data values are preserved exactly as specified.
Can I convert multi-document YAML files?
By default, Convertee converts only the first document. You can enable the 'Multi-document' option to wrap all documents in a JSON array.
Is my YAML data uploaded anywhere?
No. The YAML is parsed and converted to JSON entirely in your browser. No data is transmitted over the network.

Related Guides

Ready to convert? Try it now — no sign-up required.

Open Converter