DEVESSENTIALS

YAML Validator

Paste your YAML and get instant validation with precise error locations — line number, column, and a context snippet showing exactly where the problem is. Everything runs in your browser — nothing is sent to any server.

Paste your YAML to validate
YAML Input

What This YAML Validator Checks

The validator parses your YAML using js-yaml and reports the exact line and column of every syntax error. It catches tab characters in indentation (found character '\t' that cannot start any token), inconsistent indentation levels (bad indentation of a mapping entry), misaligned list items (bad indentation of a sequence entry), missing spaces after colons, and malformed multi-line strings.

YAML only allows spaces for indentation — a single tab causes an immediate parse error. All keys in the same mapping must start at the same column. The reported line is where the parser noticed the problem, which is often one or two lines after the actual mistake. For a detailed explanation of these errors and how to fix them, see YAML Indentation Errors Explained.

Common YAML Errors and How to Fix Them

These are the errors this validator reports most often. Each includes the exact message you will see, the root cause, and the fix.

found character '\t' that cannot start any token

Tab character used for indentation

YAML 1.2 forbids tabs for indentation — only spaces are allowed. A single tab character triggers this error immediately. Fix: search-and-replace all \t with two spaces, and configure your editor to insert spaces on Tab for YAML files. Add [*.yml] indent_style = space to .editorconfig to prevent recurrence.

bad indentation of a sequence entry

List item dash is at the wrong column

All dashes (-) in the same list must be at the same column. This error also appears when a nested object inside a list item has its keys misaligned relative to the dash. Fix: align all dashes consistently and ensure object keys inside list items start at the dash column + 2.

mapping values are not allowed here

Colon inside an unquoted value

A colon followed by a space inside a value makes the parser think it has found a new key. Most common with URLs: url: https://example.com fails because https: looks like a new key. Fix: quote the value — url: "https://example.com".

bad indentation of a mapping entry

Keys in the same object are at different columns

All keys in a mapping (object) must start at the same column. This often happens when mixing 2-space and 4-space indentation within the same block, or when pasting code from different sources. Fix: normalize indentation so every key at the same nesting level is at the same column.

duplicated mapping key

The same key appears twice in one object

A mapping cannot contain two entries with the same key at the same level. When duplicate keys exist, behavior is undefined — different parsers keep different copies. Fix: remove the duplicate. If both values are needed, rename one key or merge the values into a list.

unexpected end of the stream

File ends before the document is complete

The parser reached end-of-file while still inside an open structure — usually an unclosed block scalar (| or >), a mapping, or a sequence. Fix: check that all block scalars have at least one line of content, and that the file is not truncated. A trailing newline at end-of-file is good practice.

Related Tools

Frequently Asked Questions

What is the difference between a YAML syntax error and a semantic error?

A syntax error means the YAML is structurally invalid — wrong indentation, missing colons, unterminated strings, or illegal characters. The parser will reject it and report a line/column. A semantic error means the YAML is syntactically valid (it parses without error) but the resulting data is not what you intended — for example, an unquoted value like 'on' being parsed as boolean true instead of the string 'on'. This validator catches syntax errors. Semantic errors require knowing the expected schema.

Why does YAML use indentation for structure instead of brackets?

YAML was designed for human readability. The spec authors chose indentation (like Python) to avoid the visual clutter of JSON's braces and quotes. The tradeoff is that indentation is invisible whitespace — a single wrong space or tab creates a parse error. YAML also requires consistent indentation within each block, but the number of spaces (2, 4, etc.) is flexible as long as it's consistent at each level.

Why does YAML parse 'on', 'yes', 'true', 'no', 'false', 'off' as booleans?

YAML 1.1 (used by many libraries including js-yaml by default) defines an extended set of boolean literals: true/false, yes/no, on/off — all case-insensitive. This causes the 'Norway problem': the country code 'NO' in a YAML file becomes boolean false. To safely use these as strings, quote them: 'on', 'yes', 'no', 'off'. YAML 1.2 reduced booleans to only true and false, but library support varies.

What does the error 'bad indentation of a mapping entry' mean?

This error means a key-value pair inside a mapping (object) is not aligned consistently with other entries at the same level. YAML requires all keys in the same mapping to share the same indentation column. The most common cause is accidentally mixing tabs and spaces — YAML does not allow tabs for indentation, only spaces. Check your editor's settings to ensure it inserts spaces, not tabs, when you press Tab.

Can this validator check multi-document YAML files (separated by ---)?

The validator processes a single YAML document. If your file contains multiple documents separated by ---, js-yaml.load() will read only the first document and ignore the rest without error. Use yaml.loadAll() programmatically to process all documents. If the separator causes a parse error in your input, that's a sign your documents have structural issues.