Web Toolkit

YAML Formatter

Validate and reformat YAML, or convert it to JSON.

YAML

2
Input1 lines
Formatted YAML

Private by design. Everything runs locally in your browser. Your input is never uploaded, logged or stored on a server.

How to use the YAML Formatter

  1. Paste the YAML.
  2. Choose the output format: reformatted YAML, or the same document converted to JSON.
  3. Set the indent width.
  4. Check the parsed-document count — a stray --- separator shows up here as an extra document.

A worked example

Input
ports:
	- 8080
Output
Parse error: tab characters are not allowed for indentation

YAML forbids tabs in indentation entirely. This is the single most common reason a file that looks identical to a working one refuses to parse.

Frequently asked questions

What does this YAML formatter do?

It parses your YAML, validates it, and prints it back with normalised indentation and key ordering. Invalid documents are reported with the exact line and column.

Can it convert YAML to JSON?

Yes. Switch to the JSON tab to see the parsed document as formatted JSON, which is handy for checking how a parser interprets ambiguous values.

Why does my YAML fail with a tab error?

The YAML specification does not allow tab characters for indentation. Replace them with spaces — two per level is the common convention.

Is multi-document YAML supported?

Yes. Documents separated by --- are parsed individually and reported together.

About the YAML Formatter

YAML is whitespace-significant, which makes it pleasant to read and easy to break. This tool parses your document, reports the line and column of any error, and re-emits it with consistent indentation and quoting.

Two classes of bug dominate. The first is tabs: YAML forbids them for indentation and the resulting error rarely mentions tabs. The second is the Norway problem — bare no, yes, on and off parse as booleans in YAML 1.1, so a country code list can silently turn NO into false. Quote such values.

The JSON output tab is useful for confirming what a parser actually sees, which is not always what the indentation suggests.

What it does not do

  • Comments are dropped on reformat. YAML comments are not part of the parsed document, so they cannot be carried through.
  • Anchors and aliases are resolved when converting to JSON, so the output is expanded rather than shared.
  • It checks syntax, not meaning. A file that parses can still be invalid for the tool that consumes it.

Further reading

Related tools