How the YAML to JSON converter works
The converter parses your YAML with js-yaml 4.1.1, the YAML library used by a large part of the JavaScript ecosystem, and writes the result with the browser's own JSON.stringify. It converts as you type. Choose 2 or 4 spaces or tabs for readable JSON, or Minified for the smallest output to paste into an API call or environment variable.
Because parsing happens in your browser, it is safe to paste Kubernetes manifests, CI pipelines, Docker Compose files or app configs that contain hostnames and internal settings. Nothing is sent to a server.
JSON is a subset of YAML 1.2, so any valid JSON is also valid YAML. The reverse is not true. Comments, anchors, multi-line strings and multiple documents have no JSON equivalent, so they are resolved or dropped during conversion.
YAML 1.2 surprises: yes, no, 0755 and version numbers
js-yaml 4 follows the YAML 1.2 core schema. Older YAML 1.1 parsers such as Python's PyYAML treat yes, no, on and off as booleans. In YAML 1.2 they are ordinary strings, and only true and false (also written True/TRUE and False/FALSE) are booleans: country: NO → {"country":"NO"}, enabled: yes → {"enabled":"yes"}, ok: True → {"ok":true}. This fixes the famous “Norway problem”, where the country code NO turned into false, but it means the same file can give different results in Python and JavaScript.
Leading zeros are not octal. In YAML 1.2 octal needs a 0o prefix: mode: 0755 → {"mode":755} but mode: 0o755 → {"mode":493}. In YAML 1.1, 0755 meant octal 493. File permissions and ZIP or PIN codes are where this bites.
Version numbers are floats. version: 3.10 → {"version":3.1}. The trailing zero is gone. Quote anything that only looks like a number: version: "3.10" → {"version":"3.10"}.
Dates become timestamps. js-yaml reads an unquoted date as a timestamp, which JSON writes in ISO format: released: 2026-10-20 → {"released":"2026-10-20T00:00:00.000Z"}. Quote it to keep the plain text.
Null has several spellings. a: ~ → {"a":null}, and an empty value such as b: is also null.
When you convert JSON back to YAML, strings that a YAML 1.1 parser would misread are quoted for safety. For example {"answer":"yes","zip":"012","n":12} becomes answer: 'yes', zip: '012', 'n': 12.
Error messages with line and column
When the YAML is invalid, the converter shows the problem, the line and column (counted from 1), and the surrounding lines with a marker under the exact spot. Click Go to line to jump there in the editor. For example, a mapping with the same key twice is rejected: “Line 3, column 1: duplicated mapping key”.
The most common errors are indentation that does not line up with the parent key, a tab used for indentation (YAML only allows spaces), a missing space after a colon (key:value is read as one string, not a key and value), and an unclosed quote or bracket. Values containing : or starting with *, &, !, % or @ need quotes, or they are read as something else or rejected.
Multiple documents, anchors and merge keys
A YAML file can hold several documents separated by ---, as Kubernetes manifests often do. A single JSON value cannot, so tick Multiple documents to get a JSON array with one item per document: name: web --- name: worker becomes [{"name":"web"},{"name":"worker"}]. Without the option you get a clear error telling you to tick it.
Anchors (&name), aliases (*name) and merge keys (<<) are expanded, because JSON has no references. Keys set directly in the mapping override merged ones: base: &base ⏎ retries: 2 ⏎ job: ⏎ <<: *base ⏎ retries: 5 becomes {"base":{"retries":2},"job":{"retries":5}}.
How YAML types map to JSON types
JSON (defined in RFC 8259) has six kinds of value: object, array, string, number, true/false and null. YAML has more, so every YAML node is mapped onto one of those six. A YAML mapping becomes a JSON object and a sequence becomes an array, whether you wrote it in block style or flow style: list: ⏎ - a ⏎ - b → {"list":["a","b"]} and tags: [web, api] → {"tags":["web","api"]} give the same kind of array.
Numbers. Integers and floats become JSON numbers. YAML also accepts hexadecimal, exponent and octal forms, which JSON does not, so they are written out as plain decimals: h: 0x1F → {"h":31}, n: 1e3 → {"n":1000}. js-yaml also accepts underscores as digit separators (x: 12_000 → {"x":12000}), which the YAML 1.2 core schema does not define, so other parsers may read that value as a string.
Values that look like numbers but are not. An IP address or a clock time has more than one dot or a colon, so it stays a string: ip: 10.0.0.1 → {"ip":"10.0.0.1"}, t: 12:30 → {"t":"12:30"}. YAML 1.1 parsers read 12:30 as a base-60 number (750), another case where Python and JavaScript disagree.
Timestamps and binary. JSON has no date or binary type. A timestamp is written as an ISO 8601 string in UTC: ts: 2026-11-21T08:30:00Z → {"ts":"2026-11-21T08:30:00.000Z"}. A !!binary value is decoded and then written back as a Base64 string: data: !!binary aGVsbG8= → {"data":"aGVsbG8="}.
Explicit tags override the guess. s: !!str 123 → {"s":"123"} keeps the digits as a string without quotes, which is handy in generated files.
Multi-line strings: | literal and > folded blocks
YAML has two block scalar styles for long text, and JSON writes both as one string with \n escapes. The literal style (|) keeps every line break: text: | ⏎ line one ⏎ line two → {"text":"line one\nline two\n"}. The folded style (>) joins lines with spaces, so it suits long descriptions: text: > ⏎ line one ⏎ line two → {"text":"line one line two\n"}.
The chomping indicator controls the line breaks at the end. Plain | keeps one final newline (“clip”), |- removes it (“strip”): text: |- ⏎ line one ⏎ line two → {"text":"line one\nline two"}, and |+ keeps all trailing blank lines (“keep”): text: |+ ⏎ line one ⏎ → {"text":"line one\n\n"}. If a shell script or certificate in your config gets an unexpected trailing newline in the JSON, the chomping indicator is usually the reason.
Indentation inside a block scalar is measured from its first line, so every line of the text must be indented at least that far. A line indented less ends the block, and the parser then tries to read it as the next key.
Quoting: plain, single and double quotes
YAML has three ways to write a string, and they treat backslashes differently. Double quotes support escapes such as \t, \n and \u00e9, the same idea as JSON strings: a: "tab\there" → {"a":"tab\there"}. Single quotes have no escapes at all. A backslash is just a backslash, and the only special sequence is two single quotes for one: a: 'it''s' → {"a":"it's"}, a: 'no \t escape' → {"a":"no \\t escape"}.
Single quotes are the safest choice for Windows paths and regular expressions, where backslashes are common. Double quotes are the right choice when you need a tab, newline or Unicode escape. Plain (unquoted) strings are fine for simple words, but anything that could be read as a number, boolean, null or date should be quoted.
Keys: why numbers and booleans become strings
In JSON every object key is a string. YAML keys can be any value, so they are converted to text: 1: one ⏎ 2.5: x ⏎ true: y ⏎ null: z → {"1":"one","2.5":"x","true":"y","null":"z"}. Most programs read the result as expected, but code that looked up the number 1 in the YAML must look up the string "1" in the JSON.
Complex keys, written with ?, are flattened into a string, which rarely gives anything useful: ? [a, b] ⏎ : pair → {"a,b":"pair"}. If your YAML uses sequences or mappings as keys, restructure it before converting, for example as a list of objects with key and value fields.
Worked example: a CI workflow file
CI pipelines are a common reason to convert YAML to JSON, for example to read a workflow with a script or check it against a JSON Schema. Here is a short GitHub Actions style file, converted by this page’s parser when the page was built:
name: build
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- run: npm ci
- run: npm test{
"name": "build",
"on": {
"push": {
"branches": [
"main"
]
}
},
"jobs": {
"test": {
"runs-on": "ubuntu-latest",
"timeout-minutes": 10,
"steps": [
{
"run": "npm ci"
},
{
"run": "npm test"
}
]
}
}
}
Note that the key on stays the string "on" under YAML 1.2. A YAML 1.1 parser such as PyYAML turns that key into the boolean true, a well-known surprise when GitHub workflow files are read from Python.
Tips for clean conversions
Quote values you need as strings: IDs with leading zeros, version numbers, phone numbers and anything like 1e3, which YAML reads as the number 1000.
Watch big integers. JavaScript numbers are exact only up to 253. The converter warns you when a larger integer would lose digits, and when .inf or .nan have to become null in JSON.
Validate before you commit. Pasting a config here is a quick way to catch indentation mistakes before a deploy fails. Need to search the result for a pattern? Try the regex tester. Documenting the config? Our Markdown to HTML converter turns your README into clean HTML.
Sources and standards
The behaviour described on this page follows these specifications and library docs: the YAML 1.2.2 specification (core schema, block scalars, quoting styles and the JSON schema), RFC 8259 (the JSON data interchange format), the js-yaml documentation (load, loadAll and supported types) and the YAML 1.1 type repository for the older boolean, octal and base-60 rules. Every example above was generated by the same js-yaml build that runs the converter, so the output you see in the text is what the tool produces.