paste in · json out

YAML to JSON Converter — multi-document and all

Paste YAML and get clean JSON. Anchors, several documents in one file, and tags are all handled. It runs in your browser, so a manifest never touches a server.

Converter — Ready
Awaiting input
idle — paste YAML and the JSON shows up here
0 keys 2-space indent
runs entirely in your browser
nothing is uploaded, ever
no sign-up, no account
free — no paid tier, ever
The basics

What is a YAML to JSON converter?

A YAML to JSON converter takes a YAML document and produces an equivalent JSON file. The two formats represent the same data structures — objects, arrays, strings, numbers, booleans, null — with different syntax. YAML is more human-friendly with its indentation and minimal punctuation; JSON is more machine-friendly with its explicit braces and quotes. The converter lets you move between them losslessly.

For example, this YAML:

name: web-server
replicas: 3
image: nginx:1.25
ports:
  - 80
  - 443
environment:
  DOMAIN: example.com
  DEBUG: false

becomes this JSON:

{
  "name": "web-server",
  "replicas": 3,
  "image": "nginx:1.25",
  "ports": [80, 443],
  "environment": {
    "DOMAIN": "example.com",
    "DEBUG": false
  }
}

The data is identical. YAML's indentation becomes JSON's braces and brackets; YAML's plain strings become JSON's quoted strings. The conversion is total and lossless for the six types both formats share.

Step by step

How to convert YAML to JSON in 3 steps

Most conversions take less than a minute. No login, no upload to a server, no installation.

  1. Paste or upload

    Drop a .yaml or .yml file into the upload zone, or paste YAML text. Multi-document files (separated by ---) are supported.

  2. Configure

    Open the settings cog to choose the JSON indent (2 or 4 spaces), whether to pretty-print or minify, and how to handle multi-document YAML.

  3. Copy or download

    Click Copy JSON to put the result on your clipboard, or Download JSON to save a .json file.

Why HopConvert

Built for the YAML you actually have

Real YAML uses anchors, multi-doc files, block scalars, and custom tags. HopConvert handles all of it via js-yaml, the reference parser.

Anchors & aliases

YAML anchors (&name) and aliases (*name) are inlined automatically. The same value appears wherever it was referenced.

Multi-document YAML

Files with multiple ----separated documents parse as a JSON array. Each document becomes one element.

Block scalars preserved

Literal (|) and folded (>) block scalars convert to JSON strings with their newlines kept exactly as specified.

Browser-only privacy

Parsing happens in your browser via the js-yaml library. Nothing is uploaded, logged, or stored on our servers.

Full YAML 1.2

Powered by js-yaml 4.1, the reference YAML parser. Supports tags, type coercion, and the complete 1.2 specification.

Live preview

The result panel updates as you type. See exactly what your JSON will look like before downloading.

Comparison

YAML vs JSON: what's the difference?

Both formats store structured data, but they're designed for different jobs.

AspectYAMLJSON
SyntaxIndentation, colons, dashesBraces, brackets, commas, quotes
Best forConfiguration files, human editingAPIs, data interchange, machine-to-machine
File sizeLarger (indentation is significant)Smaller (less whitespace)
Human readabilityHigh (clean, scannable)Moderate (visual noise)
Comments# commentsNot supported
ReferencesAnchors (&) and aliases (*) — simpleJSON Pointer (complex)
Multi-line stringsLiteral block (|) or folded (>)Requires \n escapes
StandardYAML 1.2 (no RFC)RFC 8259
Use cases

When teams reach for YAML to JSON

YAML is everywhere in modern infrastructure. The conversion unlocks all of it for JSON-based tools.

API testing

Send a YAML config to a JSON-only API by converting it first. Useful for legacy systems that pre-date YAML adoption.

Frontend data binding

JavaScript apps consume JSON. Convert a YAML config to JSON and fetch it from a static file in your build pipeline.

MongoDB import

Use mongoimport with a converted YAML to seed a collection. Faster than typing JSON by hand.

Configuration diff

JSON diffs are easier to read than YAML diffs in some tools. Convert both files and use a JSON diff viewer.

Static site generators

Many SSGs (Jekyll, Hugo, Astro) accept YAML or JSON for data files. Convert to JSON if your tooling prefers it.

Kubernetes debugging

Pipe kubectl get -o yaml through the converter for a clean JSON view in your editor or API client.

The complete guide

YAML to JSON: the complete guide

Everything you need to know about the YAML format, the conversion rules, and how to handle real-world edge cases.

Read the full YAML to JSON guide

YAML syntax basics

YAML uses three structural markers: indentation for hierarchy, colons for key-value pairs, and dashes for list items. A simple document:

name: web-server
replicas: 3
image: nginx:1.25
ports:
  - 80
  - 443
labels:
  app: web
  tier: frontend

Two-space indent is the convention; three or four is legal but unusual. Tabs are forbidden in YAML — only spaces. The colon after a key must be followed by a space. A dash at the start of a line introduces a list item.

YAML is also a strict superset of JSON: any valid JSON document is also valid YAML. That's what makes the conversion lossless.

YAML's type system

YAML 1.2 has six core scalar types plus a few extras:

  • Mappings (objects): key-value collections, written as nested indentation. Become JSON objects.
  • Sequences (arrays): ordered lists, written with dashes. Become JSON arrays.
  • Strings: either quoted (with single or double quotes) or plain (no quotes, when unambiguous). Become JSON strings.
  • Integers: 42, -17, 0x2A (hex). Become JSON numbers.
  • Floats: 3.14, 1.5e10, .inf, .nan. Become JSON numbers (except .nan which becomes a string).
  • Booleans: true / false (YAML 1.2 canonical). Yes / no / on / off are YAML 1.1 and not supported in 1.2. Become JSON booleans.
  • Null: null, ~, or empty. Become JSON null.

When parsing, js-yaml infers the type based on the value's syntax. A string that looks like a number (e.g., "42" with quotes) stays a string; an unquoted 42 becomes a number. If your YAML has type-coercion bugs (e.g., a zip code 01234 becoming octal), quote it in the source YAML to force string interpretation.

Anchors and aliases

YAML anchors (&name) mark a value for reuse; aliases (*name) refer back to it. This is useful for DRY configuration:

defaults: &defaults
  retries: 3
  timeout: 30
production:
  <<: *defaults
  host: prod.example.com
staging:
  <<: *defaults
  host: staging.example.com

When this YAML is converted to JSON, the alias is inlined — both production and staging get their own copy of {retries: 3, timeout: 30}. JSON has no concept of shared references, so this is the only sensible behaviour. The result is larger than the YAML, but valid JSON.

Multi-document files

A single YAML file can contain multiple documents separated by ---:

---
apiVersion: v1
kind: Service
metadata:
  name: frontend
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend

This is common in Kubernetes for combining related resources. The converter parses each document and produces a JSON array, where each element is one document. Single-document YAML produces a single JSON object, not an array. Toggle "always wrap in array" in settings to force a consistent shape regardless of input.

Multi-line strings

YAML has two block scalar styles for multi-line strings:

  • Literal (|): Newlines are preserved exactly. Best for code, configuration blobs, and any text where line breaks matter.
  • Folded (>): Line breaks become spaces, except blank lines which become single newlines. Best for prose paragraphs.

Both styles convert to JSON strings with their newlines preserved as-is. The | style keeps \n separators; the > style folds them into spaces. JSON doesn't distinguish between the two, so the output reflects what your YAML specified.

Tags and custom types

YAML allows you to explicitly tag a value's type with a !! prefix or custom ! prefix:

name: !!str 42
date: !!timestamp 2024-12-31
binary: !!binary |
  R0lGODlhDAAMAIQAAP//9/X

Standard tags (!!str, !!int, !!bool, !!null, !!float, !!timestamp, !!binary) are honoured. Binary data is base64-decoded to a string. Timestamps become ISO 8601 strings (JSON has no native timestamp type). Custom tags produce a parse error — if you need them, register them in the settings panel or simplify the YAML.

Common edge cases

Most YAML-to-JSON conversions are straightforward, but a few patterns are worth knowing about:

  • Norway problem: The country code "NO" is interpreted as boolean false in YAML 1.1. YAML 1.2 fixed this; modern parsers (including js-yaml 4.x) read it as a string. If you're stuck on YAML 1.1, quote "NO" in the source.
  • Octal numbers: 01234 in YAML 1.1 is octal (1234 decimal). In YAML 1.2, leading zeros are just integers. Quote if you need the literal string.
  • Trailing whitespace: Preserved in plain strings but stripped in block scalars. Quote if you need exact preservation.
  • Empty values: key: (no value) is null. key: "" is an empty string. key: ~ is also null. They look the same in YAML but mean different things in JSON.
  • Comments and directives: Comments (# ...) are stripped. YAML directives (%YAML 1.2) are honoured. --- at the start of a file is a document start marker (not data); it's stripped during parsing.
  • Reserved keys at the top level: YAML 1.1's "Norway problem" and similar quirks are gone in 1.2. js-yaml 4.x is strict 1.2 — if you have older YAML, you may see errors that weren't errors before.
Tools for this job

The same job, the way you need it

Free tools for the specific version of this conversion you are actually doing.

YAML to JSON for Kubernetes

Multi-document manifests, anchors and all - plus the yq and kubectl commands.

FAQ

Frequently asked questions

Everything you need to know about converting YAML to JSON with HopConvert.

What is a YAML to JSON converter?
A YAML to JSON converter takes a YAML document and produces an equivalent JSON file. The two formats represent the same data structures (objects, arrays, strings, numbers, booleans, null) with different syntax. YAML is more human-friendly; JSON is more machine-friendly. The converter lets you move between them losslessly.
Is HopConvert free to use?
Yes. The YAML to JSON converter is 100% free with no sign-up required. There are no paid tiers, no feature gates, and no premium plans. Conversion runs in your browser so we don't pay for servers and we don't charge you.
What happens to YAML anchors and aliases?
YAML anchors (&name) and aliases (*name) are fully supported. Aliases are inlined in the JSON output — the same value appears wherever the alias was used. This is the standard behaviour for JSON, which has no concept of shared references.
Does the converter handle multi-document YAML?
Yes. Files with multiple YAML documents separated by --- are parsed as a JSON array. Each document becomes one element. Single-document YAML files produce a single JSON object, not an array — toggle 'always wrap in array' in settings if you want a consistent shape.
Is YAML 1.2 supported?
Yes. The converter uses js-yaml 4.1, the reference YAML parser, which fully supports YAML 1.2 including anchors, multi-line strings, tags, and the full type system.
How are multi-line strings handled?
YAML's literal block scalars (|) and folded scalars (>) are converted to JSON strings with their newlines preserved. The | style keeps line breaks exactly; the > style folds line breaks into spaces. JSON doesn't distinguish between them, so the output reflects what the YAML specified.
Can I convert a Kubernetes manifest YAML to JSON?
Yes. Paste any Kubernetes YAML (Deployment, Service, ConfigMap, etc.) and you'll get clean JSON suitable for kubectl apply, HTTP APIs, or programmatic processing. Multi-document YAML files produce JSON arrays.
What about YAML tags and custom types?
Standard YAML tags (!str, !!int, !!bool, !!null, !!timestamp, etc.) are honoured. Custom tags that the parser doesn't recognise will produce a parse error — register them in settings or simplify the YAML if you need them to convert.
Is my YAML data private?
Yes. Parsing happens in your browser using the js-yaml library. Your YAML is never transmitted to a server. The page uses HTTPS and runs no third-party tracking scripts during conversion.
Can I open the JSON in my editor?
Yes. The output is a standard .json file. It opens in any text editor or IDE and works with every JavaScript, Python, Ruby, Go, or Java application. Most editors will syntax-highlight and validate the JSON automatically.

Turn your YAML into JSON

Free, instant, and private — your YAML never leaves this tab.

Start Converting Read the FAQ