YAML to JSON Converter
Paste your YAML and get clean, formatted JSON instantly, right in your browser.
What Does This YAML to JSON Converter Do?
This YAML to JSON converter takes YAML text and turns it into formatted JSON while you type. Paste a config file, a workflow, an API spec or any other YAML on the left, and the matching JSON appears on the right with two space indentation and syntax colors. If the YAML has a problem, the tool tells you what went wrong and where, instead of leaving you with a blank output box.
The conversion runs inside your browser, so there is no upload step and no account. It converts in one direction only, from YAML to JSON, and it works with one YAML document at a time.
How to Convert YAML to JSON?
- Add your YAML. Paste your YAML into the YAML Input box, or click Sample to load a ready made example and see how the tool behaves first.
- Let it convert. There is no convert button. The JSON updates a moment after you stop typing, and instantly when you paste.
- Check the status line. Below the JSON Output you will see “Valid YAML” with the character count of the result. If something is wrong, a red message appears under the editors with the line and column of the problem.
- Fix any error. Edit the YAML in the input box and the output refreshes on its own. The output stays empty until the YAML is valid.
- Copy or download. Click Copy JSON to place the result on your clipboard, or Download to save it as a file named converted.json.
- Start over. Click Clear to empty the input and reset the output for your next file.
YAML to JSON Converter Features
Live Conversion
The JSON refreshes automatically as you edit, so you can see the effect of every change in real time without pressing a button or manually refreshing the page.
Syntax Highlighting
Both the YAML input and the JSON output are color coded for keys, strings, numbers, booleans and comments, which makes mistakes easier to spot.
Line and Column Errors
Invalid YAML is reported with the exact line and column, plus a short reason from the parser, so you know where to look first.
Copy or Download
Copy the result to your clipboard or save it as converted.json. Both buttons stay disabled until there is valid output to use.
Built In Sample
The Sample button loads an example with nested mappings, lists, null values, a literal block and a folded block, handy for seeing how each style converts.
Browser-Based, No Sign-Up
Your YAML is parsed securely on your own device in your browser. Nothing you paste is sent to a server, and no account is needed to use this tool for free.
How YAML Values Become JSON
Most YAML maps to JSON in an obvious way, but a few details surprise people. The table below shows what this converter produces for the most common cases.
| In YAML | In JSON | Good to Know |
|---|---|---|
| Key and value pairs | Object | Nested pairs become nested objects |
| Dash lists or [a, b] | Array | An empty list stays an empty array |
| true and false | Boolean | Written in lowercase in the output |
| null | null | Keeps the key with an empty value |
| 8080 or 1.4 | Number | A value like 1.20 becomes 1.2 |
| “quoted text” | String | Quote a value to keep it as text |
| yes, no, on, off | String | Not turned into booleans |
| 2024-01-15 | String | Dates stay as plain text |
| Literal block (|) | String | Line breaks are kept |
| Folded block (>) | String | Lines are joined into one |
| Comments (#) | Not included | JSON has no comment syntax |
How YAML to JSON Conversion Works
Converting YAML to JSON means reading the structure of the text first and only then writing it out in a different syntax. This tool does it in two steps.
Parsing the YAML
Your text is read by the js-yaml library using its JSON compatible rules. Indentation, lists, quoted text and block styles are understood, and the result is a plain data structure of objects, arrays, strings, numbers, booleans and null values.
Writing the JSON
Before anything is written, the structure is checked for values JSON cannot hold. If it passes, it is serialized with two space indentation and shown in the output panel, ready to copy or download for use in your projects instantly.
Because the parser follows JSON compatible rules, words like yes and no stay as text and dates are not converted into special date objects. The JSON you get contains only what your YAML actually said.
Why Is My YAML Not Converting?
When the output stays empty, the message under the editors explains why. These are the situations the tool checks for, and what to do about each one.
| What You See | Likely Cause | How to Fix It |
|---|---|---|
| Invalid YAML at line and column | Bad indentation, a missing colon or an unclosed quote | Go to the reported line and check the spacing and punctuation around it |
| Multiple YAML documents | The input has more than one section separated by — | Convert each document separately |
| No YAML data found | The input contains only comments or whitespace | Add at least one real key or value |
| .nan or .inf values | JSON has no way to store these numbers | Replace them with a number or null |
| Self-referencing alias | An anchor refers back to itself | Remove the circular reference |
| Too much data | Aliases expand into a very large structure | Convert a smaller part of the file |
| Parser could not be loaded | The YAML library did not download | Check your connection and reload the page |
Converting a File With Several YAML Documents
Many Kubernetes manifests and multi step config files put several YAML documents in one file, separated by a line of three dashes. JSON can only represent a single value, so this tool does not merge them or guess which one you want. It stops and tells you how many documents it found.
The fix is simple: copy one document at a time into the input box and convert each one on its own. A leading three dash line at the very top of a single document is fine.
Common Reasons to Convert YAML to JSON
Feeding Data to an API
Most web APIs and JavaScript code expect JSON. Converting a YAML config or payload lets you send or load it quickly, easily, and accurately without rewriting it by hand.
Config Files and Workflows
Docker Compose files, GitHub Actions workflows and similar configs are written in YAML. A JSON copy is useful when a script or validator only reads JSON.
Checking Your Own YAML
Seeing your YAML as JSON shows exactly how each value is understood. It is a quick way to confirm that a list is really a list and a number is really a number.
Debugging Indentation
A single misplaced space can change the meaning of YAML. The line and column error points you to the problem much faster than reading the file top to bottom.
YAML vs JSON: What Is the Difference?
Both formats store the same kinds of data: objects, lists, text, numbers, booleans and empty values. JSON uses braces, brackets and quotes, which makes it strict and easy for programs to read. YAML relies on indentation and allows comments, which makes it more comfortable for people to write and review.
That is why teams often keep configuration in YAML and hand JSON to code. Once converted, you can tidy or inspect the result further with our JSON Formatter.
Is It Safe to Convert YAML Online?
YAML files often hold things you would not want to share, such as internal hostnames, service settings or environment values. Many online converters send your text to a server to process it, which means a copy leaves your device.
This tool parses and converts everything locally in your browser. Your YAML and the JSON result are never transmitted by the tool. The only thing fetched from the network is the open source parser library when the page loads, so if that fails you will see a message asking you to reload.
Tips for Converting YAML to JSON
Quote Version Numbers
An unquoted value such as 1.20 is read as a number and shows up as 1.2. Put it in quotes if you need the exact text.
Dates Stay as Text
A date such as 2024-01-15 is kept as a string. If you need a numeric time value instead, our Unix Timestamp tool can convert it.
Keep Indentation Consistent
Use the same number of spaces for each level of nesting. Mixed indentation is the most common reason for an invalid YAML error.
Very Large Input
Conversion still works on big files, but color highlighting is switched off above about 300,000 characters to keep the editors responsive.
Frequently Asked Questions
How do I convert YAML to JSON online for free?
Paste your YAML into the input box. The JSON appears on the right automatically. Then click Copy JSON or Download to take the result with you. No account or payment is needed.
Do I need to click a convert button?
No. The tool converts as you type, shortly after you pause, and immediately when you paste text.
Can I convert JSON back to YAML with this tool?
No. This converter works in one direction only, from YAML to JSON.
Can I upload a .yaml or .yml file?
There is no file upload. Open your file in any text editor, copy its contents and paste them into the YAML Input box.
Why does the tool say my input has multiple YAML documents?
Your input contains more than one document separated by three dashes. JSON can hold only one value, so nothing is converted. Paste each document separately to convert them one by one.
Are YAML comments kept in the JSON?
No. JSON does not support comments, so anything after a # in your YAML is left out of the output.
Why are yes, no, on and off converted to strings?
The converter treats only true and false as booleans. Words like yes, no, on and off stay as text, so they appear in quotes in the JSON.
What happens to YAML anchors and aliases?
Aliases are resolved, so the referenced content is written out in full wherever it is used. An alias that refers back to itself cannot be represented in JSON, and the tool shows an error in that case.
How is the JSON formatted?
The output is pretty printed with two space indentation and syntax colors. There is no option to minify or change the indentation.
Why are the Copy JSON and Download buttons disabled?
They turn on only when there is valid JSON in the output. If the input is empty or contains an error, there is nothing to copy yet.
Is my YAML uploaded to a server?
No. Your YAML is parsed and converted inside your browser. Only the parser library itself is loaded from the network when the page opens.
Is there a size limit?
There is no fixed character limit, but the tool refuses input that expands into more than one million values, which can happen with heavily nested aliases. Color highlighting is turned off for very large text, though conversion still works.
Does this tool work on mobile devices?
Yes. On smaller screens the input and output panels stack one above the other, and all buttons work the same way as on desktop.
