Skip to content

YAML to JSON Converter

Parse YAML documents and convert to formatted JSON with error reporting and syntax validation.

YAML to JSON Converter tool

Loading...

Example

Input: name: app / ports: [80, 443] / debug: false

Result: A 2-space indented JSON object: { "name": "app", "ports": [ 80, 443 ], "debug": false }

The YAML is parsed with the core schema, so 80 stays a number and false a boolean. Dates like 2024-01-15 stay strings rather than turning into timestamps.

How YAML Values Become JSON

YAML valueJSON result
yes"yes"
on"on"
truetrue
Truetrue
~null
2024-01-15"2024-01-15"
0x1F31
1e31000
0077
"007""007"
3.103.1
.infnull

Parsed with the YAML 1.2 core schema. JSON has no Infinity, so .inf becomes null.

  1. Paste your YAML document into the input panel on the left side.
  2. The parser validates your YAML syntax and reports any errors with line numbers and descriptions.
  3. View the converted JSON output with proper indentation and formatting in the right panel.
  4. Check that nested mappings, sequences, and scalar values are correctly represented in the JSON.
  5. Click the copy button to copy the formatted JSON for use in your API calls or application code.

YAML to JSON: How Values Are Typed

This tool parses YAML and writes the same data as JSON with 2-space indentation. port: 8080 becomes "port": 8080, and a - list becomes a JSON array. It is handy when an API, a script or a JSON Schema check needs the data from a YAML config file.

YAML decides a value's type from how it looks, and parsers do not all follow the same rules. This converter uses the YAML 1.2 core schema. Under it, true and false are booleans, ~ and null are null, and numbers include forms like 0x1F and 1e3. Words like yes, no and on stay strings, unlike older YAML 1.1 parsers that treat them as booleans. Dates such as 2024-01-15 also stay strings instead of turning into timestamps. The table lists common cases.

Comments are dropped, since JSON has none. Anchors (&name) and aliases (*name) are resolved, so the shared data is copied into each place it is used. The << merge key is not expanded under the core schema, though; it shows up as an ordinary key named <<. The input must be one document. A file with several documents separated by --- shows an error, so paste them one at a time.

Syntax problems such as a tab used for indentation or a duplicate key show the parser's message with the line and column. The panels also turn JSON back into YAML. To look through a large file as a tree first, use the YAML Formatter, and to check the JSON result, the JSON Formatter.

Sources

Frequently Asked Questions

YAML 1.1 treated yes, no, on and off as booleans, which caused famous bugs such as the country code NO turning into false. YAML 1.2, used here, only accepts true and false (in lower, title or upper case) as booleans. If your app expects yes to mean true, change the value to true in the YAML.
An unquoted 007 matches the integer rule, so it is read as the number 7 and the zeros are lost. Quote values that are really codes, such as "007" or "01234", and they stay strings in the JSON. The same applies to version numbers like 3.10, which becomes 3.1 unless quoted.
Not in one go. This converter expects a single document and shows an error if it finds more than one. Paste each part between the --- lines separately. If you only need to check or tidy a multi-document file, the YAML Formatter accepts several documents at once.
Something is indented to a level YAML cannot fit into the structure, often after copying text from a web page or chat. Check the line in the message and the one above it. Each child must be indented more than its parent, siblings must line up exactly, and only spaces are allowed, never tabs.
Anchors and aliases work: every *name is replaced by a full copy of the data marked &name. The << merge key is a YAML 1.1 feature and is not part of the core schema, so it is not expanded. It appears in the JSON as a key literally named <<. Write the merged keys out in full if you need them.

Related Tools

JSON to YAML Converter

Convert JSON documents to YAML format with syntax validation, clean formatting, and instant preview.

Developer Tools

JSON Formatter and Validator

Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.

Developer Tools

YAML Formatter and Viewer

Format, validate, and visualize YAML documents with tree view and customizable indentation.

Developer Tools

YAML to TOML Converter

Transform YAML documents to TOML configuration format with proper table structure and types.

Developer Tools

JSON to CSV Converter

Convert a JSON array of objects to CSV with automatic column headers, and convert CSV back to JSON in the same tool.

Developer Tools

JSON to XML Converter

Convert JSON data to well-formed XML documents with customizable root element and formatting options.

Developer Tools