Check whether your YAML is valid and see where it breaks.
What it does
YAML Validator checks whether your text is valid YAML and, when it is not, shows where the problem is. It reads YAML under the YAML 1.2 Core rules, as one document or several separated by ---, and answers with a verdict. When the text is valid and YAML Formatter can format it, the result also shows it formatted, every document included, with the same layout YAML Formatter gives with “2 spaces” selected.
Use it before you send YAML to a program, a pipeline or a configuration file that would reject it.
What it supports
- YAML read under the YAML 1.2 Core rules, as one document or several separated by ---: plain, quoted and multi-line text, numbers, true, false, null, lists, mappings, comments, anchors and aliases.
- With several documents, the verdict is valid only when every document is valid. The line and column of a problem count from the start of the whole text.
- Anchors (&name) and aliases (*name) are checked but never expanded. An alias with no anchor, an alias that comes before its anchor and an alias that points at an anchor in another document are errors.
- A key repeated in the same mapping is an error.
- Only one problem is reported: the one nearest the start of the text. Fix it and validate again to find the next one.
- Some YAML is valid but outside what the YAML Formatter and Viewer support: a tag that is not a standard YAML tag, a key that is not text (a number, true, false, null, an empty key, or a key written as a list or mapping), and a directive such as %YAML or %TAG. The verdict is valid, and a warning says that the Formatter and Viewer cannot process it. Only the verdict is shown, with no formatted text.
- The merge key << is not part of YAML 1.2 Core. It is read as an ordinary key, with a warning.
Good to know
- Valid means the text is valid YAML. The validator does not check that the data has the keys or values your program expects.
- It never repairs YAML. There are no automatic corrections and your text is never changed: the message says what to fix, and you make the change yourself.
- A text with only comments or blank lines has nothing to validate, so you get a note asking for content, not a verdict.
- A directive such as %YAML 1.1 is only reported as a warning: the document is still read under the YAML 1.2 Core rules, whatever the directive says. Programs that follow the older YAML 1.1 rules can read some texts differently, for example when they apply merge keys.
- The formatted text always uses 2 spaces: there is no indentation option and no tree. A text that is not valid gets only the verdict. So does a valid text that YAML Formatter refuses to format, such as one with a tag that is not a standard YAML tag, and a valid text whose formatted version would be larger than 2,000,000 bytes. In those cases there is nothing to copy or download.
- YAML nested deeper than the limit is refused as beyond what the tool processes. It is not called invalid.
How to use it
- Paste or type your YAML in the input box. Nothing runs while you type.
- Press “Validate”.
- Read the verdict. “The YAML is valid.” means the text is valid YAML. “The YAML is not valid.” comes with the problem nearest the start of the text, its line and column, and the spot highlighted in your text. Warnings, if there are any, are listed under the verdict.
- When the verdict is valid and the formatted text appears, press “Copy” to put it on your clipboard or “Download” to save it as formatted.yaml.
- Fix the problem in your text and press “Validate” again. Editing your text clears the old verdict, so a verdict on screen always matches what you validated.
Examples
A valid text
Paste this text and press “Validate”. It follows the YAML rules, so the verdict is “The YAML is valid.” In the tool, the result also shows the text formatted.
name: demo
items:
- one
- two
The YAML is valid.
A repeated key
The key “name” appears twice in the same mapping, and YAML requires the keys of a mapping to be unique. The verdict is “The YAML is not valid.”, followed by the line and column of the repeat, which is also highlighted in your text.
name: demo
name: other
items: [1, 2]
The YAML is not valid.
A key is repeated in the same mapping. YAML requires the keys of a mapping to be unique. Remove or rename the repeated key.
Line 2, column 1
Valid, with a warning
The tag !money is not one of the standard YAML tags. The syntax is valid, so the verdict is valid, but a warning tells you that the YAML Formatter and Viewer cannot process this text, so only the verdict is shown, with no formatted text. The tag itself is never run or looked up.
price: !money 12.50
The YAML is valid.
The syntax is valid, but this YAML uses a tag this tool does not support: a custom or non-Core tag, or a Core tag (such as !!int) that does not fit its value. The YAML Formatter and Viewer cannot process it.
A merge key
Some YAML tools read << as a merge key, which copies the keys of an anchor into a mapping. YAML Validator follows the YAML 1.2 Core rules, which have no merge keys, so << is an ordinary key and nothing is merged. The verdict is valid, with a warning because programs that apply YAML 1.1 merging may read this text differently.
defaults: &d
retries: 3
prod:
<<: *d
retries: 5
The YAML is valid.
This YAML uses << as an ordinary key. This tool follows the YAML 1.2 Core schema, which has no merge keys, so nothing is merged in. Programs that apply YAML 1.1 merging may read it differently.
Limits and privacy
Size limits
- Input: up to 2,000,000 bytes of UTF-8 text (about 2 MB). Accented letters and emoji take more than one byte each. Larger input is rejected.
- Nesting: up to 256 levels of mappings and lists inside each other. Deeper YAML is refused because it is beyond what the tool processes.
- Time: a run that takes longer than its time limit is stopped. Try a smaller input.
Your privacy
The text you type or paste, or open from a local file, is processed locally in your browser, in a dedicated Web Worker. It is never uploaded or sent to the server (a file you open is read in your browser only), and it is not written to storage, cookies or the address bar.
“Copy” puts the result on your clipboard and “Download” saves it as a file, but only when you press the button. The file is created in your browser, so nothing is uploaded.
For the full details, see the Privacy Policy
Related tools and pages
Your text stays in the page when you switch tools in the same tab, so you can try the same text in another tool. Reloading or closing the tab ends it.