Home › File & PDF Tools › YAML to JSON Converter

YAML to JSON Converter

This free YAML to JSON converter turns YAML text into clean, pretty-printed JSON in your browser. Paste your YAML, press Convert, and get valid JSON you can copy or download as a .json file. Everything happens on your own device — nothing is uploaded to any server, so config files, API settings, and private data stay private. It also works as a quick YAML checker: if your YAML is broken, it tells you the line number instead of failing silently.

Your JSON will appear here
Paste YAML above and press Convert to JSON.

How it works

YAML and JSON describe the same kind of data — names paired with values, nested inside each other — but they look very different. YAML is built for people: it uses indentation and dashes instead of brackets, so a config file reads almost like an outline. JSON is built for code: it uses curly braces, square brackets, and quotes, so any programming language can parse it without guessing. That is why the same settings file often exists in both forms, and why developers need to move between them. This converter reads the YAML outline and rebuilds it as JSON, keeping every value, every list, and every level of nesting intact.

The conversion follows the shape of your YAML. A line such as name: Alice becomes a JSON pair, "name": "Alice". A key with nothing after its colon, followed by indented lines, becomes a nested object — so address: with city: Austin underneath becomes "address": {"city": "Austin"}. Lines that start with a dash become a JSON array, in the same order, so a tags list of red and blue becomes "tags": ["red", "blue"]. Numbers stay numbers, true and false stay booleans, and null, a tilde (~), or an empty value all become JSON null. Quoted strings keep their exact text, including spaces and punctuation that would otherwise confuse a parser.

Comments and multi-line text are handled too. Anything after a # on a line is a comment and is left out of the JSON, because JSON has no comments. A pipe (|) starts a literal block that keeps line breaks, which is how long descriptions and messages are usually written in YAML; a greater-than sign (>) starts a folded block that joins the lines into one flowing paragraph. Both come through as a single JSON string. Flow collections work as well: [red, blue] becomes an array and {city: Austin} becomes an object, so compact YAML converts just as cleanly as the indented style.

The output is pretty-printed, so it is easy to read and to paste into code, a config file, or an API test. Choose 2-space or 4-space indentation to match the style your project already uses, and turn on Sort keys if you want the output alphabetically ordered — handy when you are comparing two config files and want matching keys to line up. Use the Copy button to grab the JSON, or Download to save it as a .json file. You can also upload a .yaml or .yml file instead of pasting, and the Load sample button restores the example if you want to experiment and start over.

The converter also checks your YAML while it works, which makes it useful even when you only want to find a mistake. YAML is fussy about indentation: it must use spaces, never tabs, and lines at the same level must line up exactly. A missing space after a colon, an unclosed quote, or an unclosed bracket will stop the conversion, and the error message names the line number so you can go straight to the problem. Fix that line and convert again. That quick check saves a lot of time when a config file refuses to load and the real cause is one stray space three pages down.

A few honest limits. This is a hand-written parser for the everyday YAML subset, not a full YAML engine: anchors and aliases (&name and *name), custom tags, and multi-document files separated by --- lines beyond the first document are not supported, and very large files — tens of thousands of lines — may be slow in a browser tab. Dates are treated as plain strings, which is the safe choice, because different tools read YAML dates differently. For the everyday job of converting a settings file, a CI config, or an API example into JSON, this page is the fastest route — and because it runs entirely in your browser, you can use it on private files without a second thought.

Worked example

A developer has a small YAML settings block and needs it as JSON for a JavaScript app:

Step 1: Paste the YAML into the input box:
name: Alice
age: 30
tags:
  - red
  - blue
address:
  city: Austin

Step 2: Press Convert to JSON with 2-space indent and Sort keys off.

The validation line reports Valid YAML — converted to JSON successfully, and the output is:

{
  "name": "Alice",
  "age": 30,
  "tags": [
    "red",
    "blue"
  ],
  "address": {
    "city": "Austin"
  }
}

That is exactly the JSON the tool produces for this input — the developer copies it straight into the app, where data.tags[0] gives "red" and data.address.city gives "Austin" with no extra parsing work. Try changing a value and converting again: the output updates at once, and if you type a mistake such as a: [unclosed, the tool reports an error on line 1 instead of crashing.

FAQ

Is my YAML uploaded anywhere?

No. The conversion runs entirely in your browser with a built-in YAML parser written in JavaScript. Your text never leaves your device, so private config files and secrets stay private.

What YAML features does this converter support?

It supports mappings, nested indentation, lists, quoted strings, numbers, booleans, null values, comments, and multi-line block strings with | and >. Flow collections such as [a, b] and {a: b} work too. Advanced features such as anchors, tags, and multi-document files are not supported.

Why does it say my YAML is invalid?

The most common causes are mixed tabs and spaces, a missing space after a colon, an unclosed quote or bracket, or inconsistent indentation. The error message names the line number, so fix that line and convert again.

Does it keep the order of my keys?

Yes, by default the output keeps your keys in the same order they appear in the YAML. Turn on Sort keys if you would rather have the output alphabetically ordered, which is handy for comparing two config files.

How do I use the JSON output in my code?

Copy the output or download it as a .json file, then load it with your usual JSON tools — for example JSON.parse in JavaScript or json.load in Python. The output is valid JSON, so any standard JSON parser can read it.