YAML to JSON Converter and YAML Validator

Convert YAML to JSON instantly, with line-and-column errors that make it a YAML validator too. Free, and your config never leaves your browser.

Direction
JSON output

  
  
–

Parsed with js-yaml 4 (YAML 1.2) in your browser. Nothing is uploaded.

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.

YAML to JSON Converter: frequently asked questions

Is this YAML to JSON converter free and private?

Yes. It is free with no sign-up and no limits, and the conversion runs entirely in your browser using the js-yaml library. Your YAML is never uploaded, so it is safe for configs that contain internal hostnames or settings.

Why does "no" or "yes" stay a string instead of becoming false or true?

This converter uses js-yaml 4, which follows the YAML 1.2 core schema. In YAML 1.2 only true and false are booleans; yes, no, on and off are ordinary strings. Older YAML 1.1 parsers such as PyYAML turn them into booleans, so write true or false if you need a boolean everywhere.

How do I convert a YAML file with multiple documents?

Tick the Multiple documents option. Each document separated by --- becomes one item in a JSON array, in the same order. Without the option, a file with more than one document shows an error, because a single JSON value cannot hold several documents.

How do I find the error in my YAML?

The error message gives the line and column, counted from 1, and shows the surrounding lines with a marker under the problem. Click Go to line to jump there. Most errors come from inconsistent indentation, tabs used for indentation, a missing space after a colon, or an unclosed quote or bracket.

Are YAML comments kept in the JSON?

No. JSON has no comment syntax, so comments are dropped. Anchors and aliases are expanded into full copies and merge keys are resolved, because JSON has no references either.

How do I convert YAML to JSON on the command line?

With yq (version 4), run: yq -o=json file.yaml. With Python and PyYAML installed, run: python -c "import sys, json, yaml; print(json.dumps(yaml.safe_load(sys.stdin), indent=2))" < file.yaml. Note that PyYAML follows YAML 1.1, so values like yes and no become booleans there but stay strings in this converter.

Can I convert JSON back to YAML?

Yes. Choose JSON to YAML at the top of the tool, or open the separate JSON to YAML converter page. Your JSON is parsed and written as block-style YAML with 2 or 4 space indentation. Strings that older YAML parsers might misread, such as yes or 012, are quoted for safety.

Why did my version number 3.10 turn into 3.1?

An unquoted 3.10 is a floating-point number in YAML, and numbers have no trailing zeros, so the JSON shows 3.1. Write the value in quotes, version: "3.10", and it stays the exact string. The same applies to IDs and ZIP codes with leading zeros.

How are | and > multi-line strings converted?

Both become a single JSON string. The literal style (|) keeps each line break as \n, and the folded style (>) joins the lines with spaces. The chomping indicator decides the end: | keeps one final newline, |- removes it, and |+ keeps all trailing blank lines.

What happens to dates and timestamps?

JSON has no date type. An unquoted date or timestamp is read as a timestamp and written as an ISO 8601 string in UTC, such as 2026-11-21T08:30:00.000Z. If you want the original text unchanged, put the value in quotes.

Why are numeric keys in quotes in the JSON?

RFC 8259 requires every object key to be a string, so YAML keys such as 1, 2.5 or true are converted to "1", "2.5" and "true". Code that reads the JSON should look keys up as strings.