JSONNew

YAML to JSON Converter

Parse YAML and convert it to formatted JSON with validation

100% client-side — your data never leaves your browserNo data stored or uploadedFree for lifetime · No signup
JSON output will appear here

What does a YAML to JSON converter do?

It parses YAML — the indentation-based format used by Kubernetes manifests, CI pipelines, Docker Compose and most modern config files — and re-emits the same data as JSON. YAML and JSON describe the same structures (mappings, sequences, scalars), but YAML layers on conveniences that make it easier to write and harder to consume programmatically: comments, unquoted strings, several spellings of true and null, multi-line block scalars. Converting to JSON strips all of that ambiguity into one canonical form.

Parsing happens entirely in your browser — your config files, which often contain hostnames, ports and other internals, are never uploaded or logged.

When to use it

The classic case is feeding YAML-authored config to something that only speaks JSON: an HTTP API that expects a JSON body, a jq pipeline, a JavaScript service that reads JSON without a YAML dependency. It's equally useful as an X-ray for YAML's implicit typing — convert and you see exactly what a parser thinks you wrote. If port: 8080 comes out as a number when the consumer expects a string, or a bare yes comes out as true, the JSON output shows it immediately, with comments stripped and every string explicitly quoted.

It's also a quick sanity check before committing a manifest: if the structure that comes out isn't the structure you meant — a list item nested one level too deep, a key swallowed by a block scalar — the misindentation is much easier to spot in braces than in whitespace. Going the other way? Use the companion JSON → YAML tool.

Example

Paste a service definition like:

name: api replicas: 3 ports: - 8080 - 8443 env: DEBUG: "false"

Convert, and you get {"name": "api", "replicas": 3, "ports": [8080, 8443], "env": {"DEBUG": "false"}} pretty-printed at your chosen indent. Note the details the conversion surfaces: replicas and the ports are real numbers, while DEBUG stays the string "false" because it was quoted — exactly the distinction that causes production config bugs. Use the "Copy link to this result" button to share the conversion; the link restores your YAML for anyone who opens it.

Anchors, aliases and multi-document YAML

Anchors and aliases let a YAML file define a block once (&defaults) and reuse it elsewhere (*defaults), often combined with the merge key (<<: *defaults) in Docker Compose and GitLab CI files. This converter does not resolve them. When it meets an anchor, an alias or a merge key it stops with an error naming the line, rather than producing JSON with the reused block missing. Expand them first — yq -o json 'explode(.)' file.yaml does it in one step — or convert with PyYAML or the Node.js yaml package shown below, which resolve aliases while parsing.

Multi-document YAML uses --- to separate documents in one file, as in a Kubernetes manifest that holds a Deployment and a Service. A single leading --- is accepted and ignored. A second --- is reported as an error instead of silently dropping everything after it, because JSON has no equivalent of a document stream: convert each document separately here, or use a CLI that turns the stream into a JSON array.

Convert YAML to JSON with Python, Node.js or yq

Python (PyYAML): python3 -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin), indent=2, default=str))' < config.yaml. default=str turns the dates PyYAML creates from unquoted 2026-11-07 values into strings instead of crashing json.dumps. For a multi-document file, replace yaml.safe_load(sys.stdin) with list(yaml.safe_load_all(sys.stdin)) to get an array.

Node.js (npm i yaml): node -e 'const YAML = require("yaml"); console.log(JSON.stringify(YAML.parse(require("fs").readFileSync(0, "utf8")), null, 2))' < config.yaml. For several documents, YAML.parseAllDocuments(text).map(d => d.toJS()).

yq: yq -o json config.yaml prints JSON for each document; yq ea -o json '[.]' config.yaml collects all documents into one array. PyYAML and the Node yaml package resolve anchors and aliases while parsing; with yq, add explode(.) — yq -o json 'explode(.)' config.yaml — to be sure merge keys are expanded.

How to use the YAML to JSON Converter tool

  1. 1

    Paste your YAML

    A manifest, pipeline file, or any YAML document goes in the left panel.

  2. 2

    Pick the JSON indent

    Choose 2 or 4 spaces for the pretty-printed output.

  3. 3

    Convert

    The JSON appears on the right; a parse problem is reported below instead of producing broken output.

  4. 4

    Copy or share

    Copy the JSON, or copy a permalink that restores your exact input.

Frequently asked questions

Why did my unquoted value change type in the JSON?

YAML implicitly types bare scalars: yes/no/on/off become booleans, 8080 becomes a number, ~ becomes null. That's the spec, not a bug — and seeing it happen is half the value of converting. Quote the value in your YAML if you need it to stay a string.

What happens to my comments?

They're dropped. JSON has no comment syntax, so # comments cannot survive the conversion. If the comments matter, keep the YAML as the source of truth and treat the JSON as a generated artifact.

Does it support every YAML feature?

It covers the subset that real config files use: nested mappings and sequences, quoted and unquoted scalars, inline flow collections, block scalars (| and >), and comments. Anchors/aliases (&, *, <<) and a second document in a multi-document stream are reported as an error with the line number rather than converted; custom tags aren't interpreted. Expand those before converting.

Is my config uploaded anywhere?

No. Parsing and conversion run entirely in your browser, so manifests containing internal hostnames or settings never leave your machine. For the reverse direction, use the JSON to YAML converter.

Does it support YAML anchors and aliases?

No. Anchors (&name), aliases (*name) and merge keys (<<) are reported as an error with the line number, instead of being converted into broken output. Expand them with yq 'explode(.)', or convert with PyYAML or the Node.js yaml package, which resolve them.

Can I convert a multi-document YAML file?

One document at a time. A leading --- is fine, but a second --- produces an error. To get every document as a JSON array, use yq ea -o json '[.]' file.yaml or Python's yaml.safe_load_all.

Why did 'no' become false but 'NO' stay a string?

The converter treats lowercase yes/no/on/off as booleans, YAML 1.1 style, but leaves other spellings such as NO or Yes as strings. Other parsers differ — YAML 1.2 parsers only accept true and false — so quote any value that must stay a string.

How do I convert YAML to JSON in Python?

json.dumps(yaml.safe_load(open('config.yaml')), indent=2, default=str) with PyYAML installed. Use safe_load rather than load, so the file cannot construct arbitrary Python objects.

Related on TechLogHub

Get the next tool before you need it

One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.