{ } JSON Workbench0 network requests. Check DevTools

"YAML to JSON":{ }

Paste YAML and get valid JSON instantly. Anchors and aliases are expanded inline, merge keys (<<) are resolved, and comments are dropped (JSON has none). Powered by js-yaml, running 100% in your browser. No upload, no signup.

What is YAML to JSON conversion?

YAML is human-friendly config, the format behind Kubernetes, CI pipelines, Ansible, and Docker Compose. JSON is machine-friendly and API-native. Converting lets you feed hand-authored config into tools and APIs that only speak JSON, or validate YAML against a JSON Schema. Anchors are expanded, merge keys resolved, and comments dropped since JSON has none.

Edge cases & gotchas

  • Norway Problem: unquoted NO, YES, ON, OFF parse as booleans. Quote them to preserve strings.
  • Leading zeros / versions: 01234 may parse as a number and 1.0 becomes float 1. Quote to keep as string.
  • Multi-document streams (---): JSON has no multi-doc concept: output the first doc or a JSON array.
  • Comments lost: # lines do not transfer.
  • Indentation-sensitive: tabs are invalid; inconsistent indent is a parse error.
  • Explicit tags (!!str, custom !Tag) may be coerced or dropped; key order isn't guaranteed.

YAML → JSON value mapping

YAMLJSON
~ / null / emptynull
NO / OFF (unquoted)false
&anchor / *aliasinlined copy
<<: *anchormerged keys
--- (multi-doc)array / first doc

How to use

  1. Paste YAML into the Input pane, or upload a .yml / .yaml file.
  2. For multiple documents (---), choose first-doc or JSON-array output.
  3. Convert: js-yaml parses, resolves anchors and aliases, and emits JSON.
  4. Choose indentation (2 or 4 spaces) or minify.
  5. Copy the result or download it as .json.

Examples

Config map → object

Input
server:
  host: localhost
  port: 8080
  ssl: true
Output
{
  "server": {
    "host": "localhost",
    "port": 8080,
    "ssl": true
  }
}

Anchors, aliases & merge keys

Input
defaults: &defaults
  adapter: postgres
  host: localhost
development:
  <<: *defaults
  database: dev_db
Output
{
  "defaults": { "adapter": "postgres", "host": "localhost" },
  "development": {
    "adapter": "postgres",
    "host": "localhost",
    "database": "dev_db"
  }
}

The Norway Problem (type coercion)

Input
country: NO
Output
{ "country": false }
// quote it (country: "NO") to keep the string

FAQ

What is a YAML to JSON converter?

A tool that parses YAML (a superset of JSON) and re-serializes it as strict JSON.

Does YAML support comments, and do they survive?

YAML has # comments; JSON does not, so they are dropped.

How are anchors and aliases handled?

Expanded inline: the referenced node is copied into every location, and merge keys (<<) are flattened.

How do I convert YAML to JSON in Python, Node, or CLI?

yaml.safe_load + json.dumps (Python), js-yaml (Node), or yq -o=json (CLI).

Is my data processed locally?

Yes. js-yaml runs in your browser; DevTools → Network shows zero requests.

Can it handle multi-document YAML?

Yes, pick first-document, or emit a JSON array of documents. Need the reverse? Use JSON to YAML.

Related tools