YAML Validator
Validate YAML syntax with line and column numbers, multiple documents, and a JSON preview that lists values it cannot show exactly.
- Runs in your browser
- Tool input is not uploaded to ZeroTool servers
- Free · No Sign-Up
Scan with WeChat to share this tool
Examples, details and FAQ Worked examples, how it compares with other tools, and answers to common questions.
Understanding the Error Output
When validation fails, the error box contains:
- Reason — a plain-English description of what went wrong (e.g., bad indentation, unexpected end of stream).
- Line & Column — the exact position of the error in your input.
- Snippet — the surrounding context from the parser, often showing a caret (
^) pointing at the problem character.
Common YAML Syntax Errors
- Inconsistent indentation — YAML requires consistent use of spaces (never tabs) for nesting. Mixing 2-space and 4-space indentation on the same level causes parse errors.
- Missing colon after a key —
key valueis invalid; it must bekey: value. - Unquoted special characters — characters like
:,#,[,],{,}in values must be quoted or escaped. - Tab characters — YAML prohibits tabs for indentation. Replace all tabs with spaces.
- Duplicate keys — while some parsers allow them, duplicate keys in the same mapping block are technically invalid YAML 1.2.
Example: Valid YAML
server:
host: localhost
port: 8080
tls: true
database:
driver: postgres
name: myapp
credentials:
user: admin
password: "s3cr3t"
allowed_origins:
- https://example.com
- https://api.example.com
Example: Invalid YAML (indentation error)
server:
host: localhost
port: 8080 # error: extra space causes inconsistent indentation
The validator will report the line and column where the inconsistency is detected, making it easy to locate and fix.
Valid Is Not the Same as Correct
The validator reports syntax errors. YAML that parses can still have the wrong structure, so read the Parsed Structure preview. In this file, carrot lost two spaces of indentation:
fruits:
- apple
vegetables:
- carrot
- spinach
The validator says it is valid, and the preview shows "vegetables": ["carrot - spinach"]: the next line was joined to carrot as one string.
YAML 1.1 and YAML 1.2 Read Values Differently
This tool uses js-yaml 4.3.2, which follows YAML 1.2. PyYAML follows YAML 1.1. The same file gives different data:
| YAML | This tool (js-yaml 4.3.2) | PyYAML 6.0.3 safe_load |
|---|---|---|
debug: yes | "yes" (string) | True |
country: NO | "NO" (string) | False |
octal: 0777 | 777 | 511 |
time: 12:30 | "12:30" (string) | 750 |
If a file is read by a YAML 1.1 parser, quote values such as "NO", "yes", and "0777".
Error Messages You Will See
| Input | Message from the validator |
|---|---|
message: Error: something went wrong | bad indentation of a mapping entry (1:15); quote the value |
A tab before host: | tab characters must not be used in indentation |
timeout twice in one mapping | duplicated mapping key |
server without a colon, then an indented line | end of the stream or a document separator is expected |
Limits
-
Several documents are checked one by one. A file with documents separated by
---, such as a Kubernetes manifest with a Deployment and a Service, is read with js-yamlloadAll. When all are valid, the preview shows a JSON array with one item per document. When one has an error, each document is listed with its line range as valid or with its error, so a broken Service does not hide a valid Deployment. -
Syntax only. The tool does not check a Kubernetes, GitHub Actions, or Docker Compose schema, and it does not apply lint rules. For CI, run yamllint (
yamllint .). -
The preview is JSON. Anchors and
<<merge keys are expanded in the preview, and comments are not shown. Values that JSON cannot show as written are listed above the preview with their JSON Pointer paths; the YAML is still reported as valid. This YAML:size: .inf id: 9007199254740993 due: 2026-02-31shows
The JSON preview does not show these values as written: /size: inf has no JSON form (JSON.stringify would write null); /id: integer 9007199254740993 is outside ±(2^53 − 1), so JavaScript would round it; /due: 2026-02-31 is not a valid date or time. The preview hasnull,9007199254740992and"2026-03-03T00:00:00.000Z"in their place, so do not copy it as the data. The preview writes negative zero as-0.0and shows timestamps in UTC (2026-10-01T09:30:00+09:00appears as"2026-10-01T00:30:00.000Z").!!binarydata is listed the same way:photo: !!binary aGVsbG8=showsThe JSON preview does not show these values as written: /photo: !!binary value — JSON has no binary type, and the preview shows the bytes as an object keyed by byte index. A!!binarykey, which PyYAML 6.0.3 writes forbyteskeys (the output ofyaml.dump({b'k1': 1})), is listed with the path of its mapping:The JSON preview does not show these values as written: (root): !!binary key azE= — JSON keys can only be text. The preview writes that key the way js-yaml does:"107,49". -
js-yaml work limits. js-yaml 4.3.2 stops a document whose collections are nested more than 100 levels deep, whose merge keys (
<<) handle more than 10,000 mappings and keys in total, or that lists more than 100 mappings in one merge key. The error names the limit, for example "collections are nested more than 100 levels deep (the js-yaml default limit)", with its line and column.
Related Tools
To convert YAML to JSON or back after validating, use the YAML to JSON Converter. To check the parsed data against a schema, use JSON Schema Validator. For API description files, use OpenAPI Validator.
FAQ
What does the YAML Validator check?
It parses your YAML with js-yaml 4.3.2 and reports the error the parser finds, with its line and column: indentation errors, unexpected characters, duplicate keys, missing colons and similar. js-yaml does not reject every input that the YAML specification forbids. Of the 94 inputs that the YAML test suite (yaml-test-suite, data of 2022-01-17) marks as invalid, it accepts 14, for example --- &anchor a: b (an anchored mapping on the --- line) and a double-quoted value whose next lines are not indented (quoted: "a, then b at the start of the next line). It also reports some valid YAML as an error: a tag it does not know, such as CloudFormation's !Ref, gives "unknown tag".
How is this different from a YAML to JSON converter?
A converter assumes your input is valid and transforms it. A validator focuses on whether your YAML is syntactically correct, giving you detailed error messages to help you fix problems. This tool is designed for the 'yaml validator online' use case — diagnosing and fixing bad YAML, not converting it.
What is the Parsed Structure preview?
When your YAML is valid, the tool parses it and displays the resulting data as a formatted JSON object. This helps you visually confirm the structure matches what you expect, and lets you copy the JSON equivalent for use elsewhere. Values JSON cannot show as written, such as .inf, integers outside ±(2^53 − 1), impossible dates such as 2026-02-31 and !!binary data, are listed above the preview with their paths.
Which YAML spec is supported?
The tool uses js-yaml 4.3.2, which follows the YAML 1.2 specification. It reads all common YAML syntax, including anchors, aliases, multi-line strings, block and flow sequences and explicit type tags. A file with several documents separated by --- is read with loadAll, and each document gets its own result.
Is my YAML sent to a server?
No. Validation runs in this page's JavaScript (js-yaml), and the YAML is not sent to a server or saved in browser storage. Each time you validate, the page's analytics records the tool name and whether the YAML was valid, not the YAML itself.