YAML Formatter and Validator

Paste YAML to check it, then format it with clean indentation or convert it to JSON. The tool tells you right away if the YAML is valid, and points at the exact line and column when it is not. Everything runs in your browser, so your data stays on your device.

Paste or type YAML to check it
Indent
Result

What is YAML formatting?

YAML is a plain text format for config files and data, used by tools like Docker Compose, Kubernetes, and GitHub Actions. It uses indentation to show structure, which makes it easy to read but easy to break with a stray space or a tab. Formatting rewrites your YAML with clean, even indentation so the structure is clear, without changing any of the data. This tool formats your YAML, checks that it is valid, and can convert it to JSON when you need it.

Why use our YAML formatter

  • ·Free. No signup, no paywall, no limits.
  • ·Runs in your browser. Your YAML is never uploaded, so it is safe for private data.
  • ·Live validation. See if your YAML is valid as you type, with the exact line and column of any error.
  • ·Format or convert. Clean up the indentation, or turn your YAML into JSON, in the same place.
  • ·Your choice of indent. Use 2 or 4 spaces, and sort keys when you want them in order.

YAML formatter options

Format

Reads your YAML and writes it back out with clean, even indentation. Fixes uneven spacing and normalises the layout without changing any of the data.

Beforename: peartools free: trueAftername: peartools free: true

To JSON

Converts your YAML into JSON, using the same keys and values. Useful when a tool or API wants JSON but your config is written in YAML.

Beforea: 1 b: - 2 - 3After{ "a": 1, "b": [2, 3] }

Indent

Choose 2 or 4 spaces for each level. YAML uses spaces for indentation, never tabs, so both options keep the file valid.

Beforelist: - a - bAfterlist: - a - b

Sort keys A to Z

Puts the keys of every mapping in alphabetical order, all the way down. Sequence order is left alone, since the position of items in a list has meaning.

Beforename: pear age: 2Afterage: 2 name: pear

YAML mistakes that change your data without an error

Some YAML is valid but does not mean what you think. The formatter shows the parsed result, which is the quickest way to catch these. Each example below was checked with this tool:

You writeIt is read asFix
version: 1.10The number 1.1Quote it: version: "1.10"
zip: 01234The number 1234, losing the zeroQuote it: zip: "01234"
country: NOThe text NO in this tool, but false in older YAML 1.1 toolsQuote it to be safe: country: "NO"
enabled: yesThe text yes here, but true in YAML 1.1 toolsUse true or false for real booleans
time: 12:30The text 12:30 here, but a number (750) in some YAML 1.1 toolsQuote times and anything with a colon

This tool follows YAML 1.2, where only true and false are booleans. Some tools still read YAML 1.1, where yes, no, on, and off are booleans too, so quoting these values keeps the file safe everywhere.

Common YAML errors and what they mean

  • ·“Tabs are not allowed as indentation”. YAML only allows spaces for indenting. Replace the tabs with spaces, then click Format.
  • ·“Nested mappings are not allowed in compact mappings”. You have two colons on one line, like a: b: c. Put the inner key on its own indented line, or quote the value if the colon is part of the text.
  • ·A list item or key in the wrong place. Items at the same level must start in the same column. One extra or missing space moves an item into the wrong parent, so check the line the error points to and the line above it.

When to format YAML

YAML runs the config for a lot of modern tools, and small spacing mistakes break it. Here are the most common reasons people format and check it:

  • ·Fixing a broken config. Find the tab or uneven indent that is stopping a Docker Compose or CI file from loading.
  • ·Cleaning up a pasted file. Fix the indentation of YAML you copied from a doc or a chat before you commit it.
  • ·Converting to JSON. Turn a YAML config into JSON for a tool or API that only takes JSON.
  • ·Checking a Kubernetes manifest. Validate a manifest and read its structure before you apply it.
  • ·Comparing two files. Sort the keys of both so the same fields line up and the real differences stand out.

If you work with other config and data formats, these tools run the same way, right in your browser:

Frequently asked questions

What is a YAML formatter?
A YAML formatter reads YAML that has uneven or messy indentation and writes it back out with clean, even spacing. It does not change the data, only the layout. This tool also checks that your YAML is valid and can convert it to JSON when you need it.
How do I format YAML?
Paste your YAML into the input box. The tool checks it as you type and shows a green Valid YAML message when it is correct. Pick your indentation, then click Format to see the clean version below. Click the copy button to copy it, or download it as a .yaml file.
How do I know if my YAML is valid?
The status bar under the input box updates live. If the YAML is valid, it shows a green check. If something is wrong, it shows the line and column of the problem along with a short message, so you can jump straight to the spot that needs fixing. YAML is sensitive to indentation, so most errors come from spaces.
Can I convert YAML to JSON?
Yes. Click To JSON and the tool converts your YAML into JSON with the same keys and values, formatted with your chosen indentation. This is useful when a tool or API expects JSON but your config or data is written in YAML.
Does sorting the keys change my data?
No. Sorting only reorders the keys inside each mapping into alphabetical order, which YAML treats as the same data. The values stay exactly as they were, and sequences (lists) keep their original order because the position of items in a list can be meaningful.
Why does it say my YAML is invalid?
The most common causes are using tabs instead of spaces, uneven indentation, a missing space after a colon, or a value that needs quotes. The error message points at the line and column where the parser stopped, which is usually at or just before the real mistake.
Is my YAML kept private?
Yes. All formatting, validating, and converting runs in your browser. Your YAML is never uploaded to a server or saved anywhere, so you can safely paste in data that contains private values. Once the page has loaded you can even use it offline.