Free tool
YAML to JSON & JSON to YAML Converter
Convert YAML to JSON or JSON to YAML in your browser with clear errors. Unsafe YAML such as custom tags, duplicate keys and alias bombs is rejected.
Runs entirely in your browser. Nothing you type or upload is sent to our servers.
How to convert YAML to JSON
- Paste one YAML document, or switch to JSON to YAML and paste JSON.
- The result appears as you type. Pick the indent and whether to sort keys.
- Copy or download it. If something is wrong, the message names the problem and the line where it was found.
Worked example: YAML to JSON
This YAML has a quoted ZIP code, a version number, a boolean, a null and two lists:
name: QueenNexa
version: 1.10
zip: "02134"
active: true
owner: null
tags:
- tools
- guides
limits:
max: 5
The JSON keeps "02134" as text because it was quoted, turns 1.10 into the number 1.1, and turns owner: null into null:
{
"name": "QueenNexa",
"version": 1.1,
"zip": "02134",
"active": true,
"owner": null,
"tags": [
"tools",
"guides"
],
"limits": {
"max": 5
}
}Worked example: JSON to YAML
Here "yes" and "123" are strings, so they are written quoted where reading them back unquoted would change their type:
{"service":"api","ports":[80,443],"debug":false,"note":"yes","count":"123"}service: api
ports:
- 80
- 443
debug: false
note: "yes"
count: "123"
What is rejected, and why
- Custom or language-specific tags such as
!!python/object. They are never turned into objects. - Duplicate keys in the same mapping, because the result would depend on which one wins.
- Heavy aliasing, to stop inputs that expand into enormous output.
- Several documents in one input, .inf and .nan values (JSON cannot store them), and input over 1,000,000 characters.
The parser is the open-source yaml package under the ISC licence. Tidy or check the result with the JSON formatter, turn it into a spreadsheet with JSON to CSV, or convert markup with XML to JSON. To see what changed between two config files, use Text Compare.
Frequently asked questions
Is my YAML or JSON uploaded?
No. Both conversions run in your browser, and nothing is sent to a server or stored. The YAML parser is loaded only when you use this page. That makes it reasonable to paste configuration files, though you should still remove secrets such as passwords and API keys before sharing any output with other people.
Why was my YAML rejected because of a tag?
Tags such as !!python/object or !custom tell some YAML loaders to build objects in a particular programming language, which is a known way to run unwanted code. This converter never builds objects from tags. It accepts standard YAML data only and shows an error naming the tag, so you can remove it and convert the plain data.
What happens with anchors and aliases?
Anchors (&name) and aliases (*name) are expanded, so the JSON contains a full copy of the shared data in each place it is used. To stop "alias bomb" inputs that expand into huge output, the converter limits how much aliasing a document may use and shows an error instead of freezing your tab. Ordinary files with a handful of aliases convert normally.
Why do yes, no and on stay as text?
This converter turns only true and false into JSON booleans. Words such as yes, no, on and off are kept as text, so a value like country: no stays the string "no". Numbers such as 1.10 become the number 1.1, so quote a value like "1.10" in the YAML if you need the trailing zero.
Can it convert YAML files with several documents?
Not in one pass. A file with documents separated by --- shows a message asking you to convert one document at a time, because one JSON output cannot hold several top-level values without inventing a wrapper. Paste each document on its own to convert them.
Does JSON to YAML keep strings that look like other types?
Yes. When writing YAML, the converter quotes a string such as "true", "123", "null" or "yes" so reading the YAML back gives the same string rather than a boolean, number or null. Text with line breaks and strings that contain a colon and a space are written in a form that reads back unchanged.
Are there size limits or other warnings?
Input up to 1,000,000 characters is accepted. Warnings appear when an integer is larger than 9,007,199,254,740,991 and was rounded, or when non-text keys such as 1 or true were written as text, because JSON object keys are always strings. Duplicate keys in one mapping are an error.
Link to this tool
Found it useful? Copy a link for your page, newsletter or documentation.
Get new tools and guides by email
Optional. The tool above works without signing up.
More free tools
Browse all developer tools or the full list of free tools.
- XML to JSON ConverterConvert XML to JSON with your browser's own XML parser. Attributes, repeated elements and CDATA are handled, and DTDs with entities are refused.
- CSS Gradient GeneratorBuild linear and radial CSS gradients with a live preview, up to eight color stops and opacity, then copy the CSS. Nothing is uploaded or stored.
- CSS Box Shadow GeneratorDesign a CSS box shadow with sliders, stacked layers, inset shadows and opacity, see it live, and copy the box-shadow CSS. Runs entirely in your browser.
- chmod Calculator (Octal and Symbolic)Convert Unix file permissions between octal like 755 and symbolic like rwxr-xr-x, apply symbolic changes, and copy the chmod command. Runs in your browser.
- Barcode Generator (Code 128, EAN-13, UPC-A)Create Code 128, EAN-13 and UPC-A barcodes with the check digit calculated for you, then download SVG or PNG. Input is validated and stays in your browser.
- Emoji Copy and PasteSearch about 1,900 emoji by name or keyword, browse them by category, and copy any of them with one click. The emoji you pick are never sent anywhere.