YAML formatter and validator
Tidy and check YAML with its comments kept, see exactly where it is broken, convert it to and from JSON, and find your way in it as a tree. It runs on your device: nothing is sent.
How it works
Paste YAML on the left, type it, drop a file on it, or open one. The result appears on the right as you type.
- Format writes it out again with an even indentation of 2 or 4 spaces, one value to a line, and no folding of long lines. Comments, anchors (
&name), aliases (*name) and tags (!tag) stay where they were. - To JSON converts it to JSON. Aliases and merge keys (
<<: *defaults) are filled in, and large whole numbers are kept exactly. - To YAML does the opposite: paste JSON and get YAML, with short lists of plain values kept on one line, as in
tags: [classic, fable]. - Use as input puts the result in the input, to convert it back.
When the YAML is broken
The first problem is named in words, with its line and column, and marked in the input. “Show me” puts the cursor there. The most common ones are a tab used to indent a line (YAML indents with spaces only), a line indented one space too few or too many, a key that appears twice in the same mapping, a quote or a bracket that is never closed, and two keys on one line (a: b: c).
Finding your way in it
Choose Tree to see the data as a tree. Each mapping and list folds and unfolds, with its number of keys or items. Search for a key or a value: every match is found, its branches opened, and Enter goes to the next. Choose a value to see its path, such as $.books[2].title, and copy the path, or the value as YAML. The arrow keys move through the tree.
Private by design
Everything happens on your device. The page sends nothing you type or open, and keeps nothing once it is closed.
Questions and answers
Is the YAML I paste sent anywhere?
No. It is read, checked and converted in your browser, on your device. The part that reads YAML is downloaded the first time you change the input, like the rest of the page; nothing you paste or open is uploaded, and nothing is kept once you close the page.
Are my comments kept when I format?
Yes. Formatting changes the indentation and the spacing, and keeps every comment, anchor, alias and tag where it was. Only the conversion to JSON leaves comments out, since JSON has none, and it says so.
Why does a tab cause an error?
YAML allows only spaces for indentation. A tab looks the same as a few spaces on the screen but is not, so a file that mixes them is read differently from how it looks. The formatter names the line and marks the tab.
What happens to a file with several documents?
A file can hold several documents, each starting with a line of three dashes (---). Formatting keeps them apart. Converting to JSON writes them as one list, one item per document, in order.
Why does yes stay a word, and not become true?
The formatter reads YAML 1.2, the current version, where only true and false are true and false. In the older YAML 1.1, yes, no, on and off were too, which turned the country code NO into false. Here they stay text.
Runs on your device. Nothing you type or open is sent anywhere.