YAML ↔ JSON Converter

YAML Input
JSON Output

How to Convert YAML to JSON

YAML is a superset of JSON, so most valid YAML converts cleanly to JSON. Paste your YAML into the left panel and click Convert (or just start typing — conversion happens automatically). The right panel shows formatted, indented JSON. Arrays, nested objects, and quoted strings are all handled correctly.

Everything runs in your browser. Your YAML is never uploaded, logged, or sent to a server, which matters because config files routinely contain hostnames, internal service names, and occasionally secrets that should never touch a third party's logs. You can confirm this by opening your browser's network tab and converting — there are no outbound requests.

YAML in
server:
  host: api.example.com
  port: 8080
  tags:
    - production
    - eu-west
  tls: true
JSON out
{
  "server": {
    "host": "api.example.com",
    "port": 8080,
    "tags": [
      "production",
      "eu-west"
    ],
    "tls": true
  }
}

How to Convert JSON to YAML

Switch to "JSON → YAML" mode using the toggle above. Paste your JSON in the left panel and the converter outputs clean YAML. JSON always produces valid YAML since JSON is a valid YAML subset. Use "Use as Input" to chain multiple conversions.

This direction is lossless in the strict sense — every JSON value has a YAML representation — but it is not reversible in the sense people usually expect. Comments in your original YAML are gone forever once you convert to JSON, because JSON has nowhere to put them. If you are round-tripping a config file through JSON to run a transformation, expect to reapply comments by hand. Anchors, aliases, and custom tags are likewise flattened.

YAML vs JSON: Key Differences

FeatureYAMLJSON
ReadabilityHigh — uses indentation and minimal punctuationModerate — requires braces, brackets, and quotes
CommentsSupported (# prefix)Not supported
Data typesRich — includes dates, binary, anchorsBasic — string, number, boolean, null, array, object
File sizeGenerally smaller due to less punctuationSlightly larger but more explicit
Parsing speedSlower — the grammar is significantly more complexVery fast — minimal grammar, native support everywhere
Common use casesConfig files (Docker, Kubernetes, CI/CD)APIs, data interchange, storage

YAML Features That Have No JSON Equivalent

Four YAML constructs simply cannot survive the trip to JSON. Knowing which ones you are using tells you in advance what the conversion will cost.

Comments

Anything after an unquoted # is a comment. JSON has no comment syntax at all, so comments are silently dropped. This is the single most common surprise when teams convert a hand-maintained Kubernetes manifest to JSON and then convert it back.

Anchors and aliases

YAML lets you define a node once with &name and reuse it with *name, optionally merging with <<. The converter resolves these — it expands the reference and inlines the value — so the JSON is correct but the deduplication is lost.

defaults: &defaults
  retries: 3
  timeout: 30

staging:
  <<: *defaults
  host: staging.example.com

Converts to JSON in which staging contains a full literal copy of retries and timeout. Convert back to YAML and you get the expanded form, not the anchors.

Multiple documents in one file

YAML files can hold several documents separated by ---, which is how a single Kubernetes manifest declares a Deployment and a Service together. JSON has exactly one root value, so a multi-document YAML file has no direct JSON equivalent — this converter reports expected a single document in the stream rather than guessing. Convert each document separately, or wrap them in a JSON array yourself.

Native dates and non-string keys

YAML parses an unquoted 2024-03-15 into a real date type and permits numbers, booleans, or even sequences as mapping keys. JSON has neither. The date is serialised as a full ISO 8601 instant — "2024-03-15T00:00:00.000Z", with a midnight UTC time you never wrote — and non-string keys are coerced to strings. Quote the value if you want the original text preserved exactly.

Five YAML Gotchas That Break Conversions

Most "the converter is wrong" reports are actually YAML behaving exactly as specified in ways that surprise people. These are the five worth memorising.

1. Values that look numeric lose information. A version string written as version: 1.10 is parsed as a float and becomes 1.1 — the trailing zero is gone, and 1.10 and 1.1 are now indistinguishable. A ZIP code written as zip: 02134 becomes 2134, dropping the leading zero. Quote anything that is an identifier rather than a quantity: "1.10", "02134".
2. The Norway problem — and why your parser matters. In YAML 1.1, the unquoted values yes, no, on, off, y, and n are booleans, so a country-code list containing NO for Norway parses as false. YAML 1.2 narrowed booleans to true/false only. This tool follows 1.2, so NO stays the string "NO" here — but PyYAML and many Ruby, Java, and Go libraries still implement 1.1, which means the same file converts differently depending on the parser. Quoting is the only portable fix.
3. Tabs are illegal for indentation. YAML forbids tab characters as indentation. This converter reports tab characters must not be used in indentation with a line and column, but many parsers give a vaguer message pointing well past the real culprit. If a YAML error makes no sense, search the file for a literal tab first.
4. Duplicate keys are a spec violation your parser may not catch. Defining the same key twice in one mapping is invalid YAML. This converter rejects it outright with duplicated mapping key. Plenty of 1.1-era parsers instead accept it silently and keep the last occurrence — so a stray duplicate quietly overrides the value you intended, and the file only breaks once it reaches a stricter parser.
5. Block scalar indicators change trailing newlines. | keeps the final newline, so line1\nline2\n; |- strips it, giving line1\nline2; and > folds the lines into line1 line2\n. When an embedded certificate or SSH key fails validation after a conversion, a missing or extra trailing newline is the usual cause.

How YAML Values Map to JSON Types

This is the conversion this tool actually performs — every row below is the literal output you get by pasting the input on the left. It follows the YAML 1.2 core schema. When output surprises you, check the input against this first.

YAML inputJSON outputNote
port: 80808080Unquoted digits become a number
port: "8080""8080"Quoting forces a string
tls: truetrueBoolean
tls: yes"yes"A string under YAML 1.2 — but true under 1.1 parsers
value: (empty)nullAn empty value is null, not an empty string
value: ~null~, null, and empty are all null
zip: 021342134Leading zero lost — quote it
version: 1.101.1Parsed as a float — quote version strings
mode: 0o755493Explicit 0o prefix is octal
when: 2024-03-15"2024-03-15T00:00:00.000Z"Becomes a full ISO instant, not a date-only string
big: 1e31000Scientific notation resolves to a number

Where YAML to JSON Conversion Actually Comes Up

Three situations account for most conversions.

Feeding config to a tool that only speaks JSON. Kubernetes manifests, Docker Compose files, and GitHub Actions workflows are authored in YAML, but plenty of validators, policy engines, and diffing tools accept JSON only. Converting is the bridge. Since kubectl accepts both formats natively, the conversion is usually for the surrounding tooling rather than the cluster.

Inspecting an API response as config. APIs return JSON; when you need to commit part of that response into a config file, YAML is far easier to review in a pull request. Converting JSON to YAML before committing produces a diff a human can actually read.

Debugging indentation. When a YAML file is not doing what you expect, converting it to JSON shows you the structure the parser actually built. If a key landed one level deeper than intended, the JSON braces make it obvious immediately. This is the fastest way to diagnose a misindented CI pipeline — and if that pipeline runs on a schedule, our cron expression generator will tell you exactly when the schedule fires.

Converting Between Other Formats

YAML and JSON are two points in a wider set of data formats, and the same document often has to reach all of them. Once your YAML is JSON, three neighbouring conversions cover almost everything else.

Checking and reshaping the JSON itself. Our JSON formatter and validator beautifies, minifies, and sorts keys, and reports syntax errors by line and column. Sorting keys on both sides before a diff is the fastest way to tell a real config change from a reordered export.

Getting the data into a spreadsheet. When a config or an API export has to reach someone who works in Excel or Sheets, JSON ↔ CSV flattens nested objects into dot-notation columns and parses them back into nested JSON afterwards.

Talking to systems that predate JSON. SOAP APIs, RSS feeds, Maven builds, and .NET configuration are all XML. XML ↔ JSON handles attributes, CDATA, and repeated elements, and is usually the first step when migrating legacy configuration onto a YAML-based toolchain.

Deploying the config you just converted? Managed platforms like DigitalOcean App Platform and Render read a YAML spec from your repository and handle the build, so a validated file is the whole deployment step. These are affiliate links — they cost you nothing and help keep these tools free.

Frequently Asked Questions

Is every JSON file valid YAML?
Under YAML 1.2, yes — JSON is a strict subset, so any JSON document is also valid YAML. The reverse is not true: YAML supports comments, anchors, multiple documents, and native dates that JSON cannot express.
Is my data uploaded anywhere?
No. Conversion runs entirely in JavaScript in your browser. Nothing is transmitted, stored, or logged, so it is safe to paste config files containing internal hostnames.
Why did my comments disappear?
JSON has no comment syntax, so comments cannot be preserved. If you need them, keep the YAML file as the source of truth and treat the JSON as generated output.
Why is my quoted number now a string?
That is correct behaviour. Quoting in YAML explicitly requests a string. Remove the quotes if you want a JSON number — but leave them on ZIP codes, version strings, and phone numbers, which break when parsed as numbers.
Can it handle a multi-document Kubernetes manifest?
JSON allows only one root value, so a file with --- separators has no single JSON equivalent. Convert each document individually, or combine them into a JSON array yourself.
Is there a file size limit?
No hard limit — you are bounded only by your browser's memory. Files of a few megabytes convert without trouble; very large documents may briefly freeze the tab while parsing.