ToolNimba Browse

🔁 YAML to JSON Converter

By ToolNimba Web Dev Team · Updated 2026-06-19

JSON result
 

Paste YAML above, then choose Convert to JSON. Supports common YAML, not every edge case.

This converter turns YAML into JSON right in your browser. Paste a YAML document, choose your indentation, and get clean, pretty-printed JSON you can copy in one click. It understands the YAML most people actually write day to day: key: value pairs, nested maps by indentation, dash lists, quoted and unquoted scalars, comments, and basic numbers, booleans and null. Nothing is uploaded, so it is safe for config files and secrets, the parsing happens entirely on your machine.

What is the YAML to JSON?

YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation) describe the same kind of data: scalars, lists (sequences) and key-value maps (mappings). YAML was designed to be easy for humans to read and write, so it leans on indentation and dashes instead of the braces, brackets and quotes that JSON requires. JSON, by contrast, is the format machines and APIs speak. Converting from YAML to JSON is mostly a matter of making that structure explicit: every indented block becomes an object, every dash list becomes an array, and every bare scalar gets quoted or typed.

This tool uses a hand-written, indentation-based parser rather than a full YAML engine. It walks the document line by line, tracks how deeply each line is indented, and builds the matching nested structure. A line like name: Ada becomes a string field, a line of dash items becomes an array, and a key with nothing after the colon followed by more deeply indented lines becomes a nested object or list. Unquoted values are type-inferred when that option is on, so 36 becomes a number, true and false become booleans, and null (or ~) becomes JSON null. Anything in single or double quotes is always kept as a string.

Because it targets the common subset, it deliberately does not implement every corner of the YAML 1.2 specification. Flow style ({a: 1, b: 2} and [1, 2, 3] on one line), anchors and aliases, multi-document streams beyond simple --- separators, block scalars (the pipe and the greater-than folding styles), complex keys, and merge keys are not supported. For everyday config files, CI pipelines, Kubernetes manifests and similar documents this covers the vast majority of cases. If you hit a feature it does not handle, the parser reports the line so you can adjust it, rather than producing silently wrong output.

When to use it

  • Turning a config file (for a CI pipeline, Docker Compose, or app settings) into JSON for a tool that only accepts JSON.
  • Quickly checking the structure a YAML file will produce, since JSON makes nesting and types explicit.
  • Pasting an API example written in YAML and converting it to JSON to drop into code or a request body.
  • Teaching or learning how YAML indentation maps onto objects and arrays by seeing the JSON side by side.

How to use the YAML to JSON

  1. Paste or type your YAML into the input box (or press Load sample to see an example).
  2. Pick how much to indent the JSON output: 2 spaces, 4 spaces, or a tab.
  3. Leave Infer types on to turn numbers, true/false and null into real JSON values, or turn it off to keep everything as strings.
  4. Press Convert to JSON and read the result, then press Copy to put it on your clipboard.

Formula & method

Each indented block maps to a JSON object, each dash (-) list maps to a JSON array, and each scalar is either quoted as a string or, when type inference is on, converted to a number, boolean (true or false) or null. Indentation depth determines nesting.

Worked examples

A flat YAML document with three fields and type inference on.

  1. Input: name: Ada then age: 36 then admin: true
  2. name has an unquoted text value, so it becomes the string "Ada"
  3. age is the digits 36, which type inference converts to the number 36
  4. admin is the word true, which becomes the boolean true

Result: { "name": "Ada", "age": 36, "admin": true }

A key whose value is a nested list of strings.

  1. Input: skills: on its own line, then two more-indented lines, each a dash item
  2. - math and - code are more indented than skills, so they belong to it
  3. Each dash item is a scalar, giving an array of two strings
  4. skills therefore maps to the array ["math", "code"]

Result: { "skills": ["math", "code"] }

A list of objects, where each dash item starts an inline map.

  1. Input: projects: then - title: Engine with a following line year: 1843
  2. The dash begins a list item, and title: Engine starts a map on that same line
  3. year: 1843 is indented under the dash, so it joins the same object
  4. projects becomes an array holding one object

Result: { "projects": [ { "title": "Engine", "year": 1843 } ] }

How common YAML values convert to JSON (with type inference on)

YAMLJSONNote
key: hello"key": "hello"Unquoted text stays a string
count: 42"count": 42Digits become a number
rate: 3.14"rate": 3.14Decimals become a number
enabled: true"enabled": truetrue / false become booleans
note: null"note": nullnull or ~ become JSON null
name: "42""name": "42"Quotes force a string, no inference

YAML features this converter supports and does not support

FeatureSupported
key: value maps (block style)Yes
Nested maps by indentationYes
Dash (-) sequences and lists of mapsYes
Single and double quoted scalarsYes
Comments and --- document markersYes
Flow style {a: 1} or [1, 2]No
Anchors, aliases and merge keysNo
Block scalars (pipe and folded)No

Common mistakes to avoid

  • Indenting with tabs instead of spaces. YAML does not allow tab characters for indentation, only spaces. Mixing or using tabs is the single most common cause of a parse error. The converter flags the line so you can replace the tab with spaces.
  • Inconsistent indentation levels. Every key inside the same block must line up at the same column. If one line is indented by two spaces and a sibling by three, the structure becomes ambiguous and the parser reports the offending line.
  • Forgetting that quotes change the type. Writing zip: 06010 without quotes makes it the number 6010 and drops the leading zero. Wrap values like postal codes, version strings and IDs in quotes so they stay strings.
  • Expecting unsupported YAML features to work. Flow style, anchors and aliases, and block scalars are part of YAML but outside this common subset. If your document relies on them, the conversion may stop with an error rather than guess.

Glossary

YAML
A human-friendly data format that uses indentation and dashes to describe maps, lists and scalars. The name stands for YAML Ain’t Markup Language.
JSON
JavaScript Object Notation, a compact data format using braces, brackets and quotes that APIs and programs read directly.
Scalar
A single value such as a string, number, boolean or null, as opposed to a list or a map.
Mapping (map)
A set of key-value pairs, which becomes a JSON object. In block YAML each pair sits on its own indented line.
Sequence
An ordered list of items, written with a dash in front of each one, which becomes a JSON array.
Type inference
Deciding whether an unquoted value is a number, boolean or null rather than leaving it as plain text.

Frequently asked questions

How do I convert YAML to JSON?

Paste your YAML into the input box, choose an indentation width, and press Convert to JSON. The tool parses the indentation and dashes into nested objects and arrays, then shows pretty-printed JSON you can copy. Everything runs in your browser.

Is my YAML uploaded anywhere?

No. The conversion happens entirely on your device with client-side JavaScript. Nothing is sent to a server, so it is safe to paste config files or other sensitive content.

Why do numbers and true or false change in the output?

With Infer types on, unquoted values like 42, 3.14, true, false and null are converted to real JSON numbers, booleans and null. If you want to keep them as text, wrap them in quotes or turn type inference off.

Which parts of YAML are not supported?

This is a common-subset parser. Flow style such as {a: 1} or [1, 2], anchors and aliases, merge keys, multi-document streams beyond simple --- markers, and block scalars (the pipe and folded styles) are not handled. Block maps, lists and scalars all work.

Why am I getting a parse error?

The most common causes are tabs used for indentation (only spaces are allowed) and inconsistent indent levels within a block. The error names the line number, so check that line and its siblings line up at the same column.

Can I control how the JSON is indented?

Yes. Choose 2 spaces, 4 spaces, or a tab from the Indent menu before converting. The output is always pretty-printed for readability, and you can copy it with one click.