YAML to JSON Converter — Convert Online
Convert YAML to JSON (safe schema, anchors and merge keys, error line)
Runs in your browser · nothing is uploaded
What it is
Configuration is often written in YAML while programs exchange data as JSON. This tool converts YAML to JSON. The result updates as you type, and syntax errors are reported by line and column.
How to use
- Paste your YAML into the input.
- Choose 2 spaces, 4 spaces, tab or Minify for the JSON output.
- Copy the result.
- If an error shows a line and column, check indentation, quotes and the space after colons near that spot.
How it works
- Parsing uses js-yaml with the YAML 1.2 core schema. Only
true/false,null(or~), decimal, octal and hex integers and floating-point numbers are read as booleans, null and numbers. Everything else is a string, and a quoted"123"is always a string. - Custom tags and code tags such as
!!js/functionare not supported and produce an error. Nothing is ever run as code. - Anchors (
&) and aliases (*) are expanded into values, and the<<merge key is resolved. A repeated key in one mapping is an error. - Error positions are 1-based lines and columns.
- Multiple documents are wrapped in an array. Empty input is an error.
- Values JSON cannot represent are converted by JSON’s own rules, so
.infand.nanbecomenull. Integers beyond 2^53 are rounded when read as JavaScript numbers.
Examples
Input:
base: &b
x: 1
item:
<<: *b
name: 홍길동
Result:
{"base": {"x": 1}, "item": {"x": 1, "name": "홍길동"}}
FAQ
Is a tag like !!js/function executed?
No. The tool uses a safe schema that reads plain data only (strings, numbers, booleans, null, arrays and objects). Custom tags and functions are never run and are reported as errors.
Where do I see what is wrong with my YAML?
On failure the tool shows the line and column where the problem was detected, along with the parser's explanation. Bad indentation and unclosed quotes or brackets are typical causes, and the detected spot can come just after the real cause, so look at the lines above it too.
Do yes, no, on and off become booleans?
No. Following YAML 1.2, only true and false are booleans, while yes, no, on and off stay strings. A date-like value such as 2024-01-02 also stays a plain string rather than becoming a date object.
Why do I get a "too many aliases" error?
For safety a document may contain at most 100 aliases. Inputs that nest aliases to blow the output up exponentially (an alias bomb) can freeze a browser tab, so the tool limits both the alias count and the result size (about 5 MB). Ordinary configuration files stay far below these limits.
What if the input has several documents separated by ---?
One document gives its value. Two or more give a JSON array of the documents in order, and a note tells you how many were found.