YAML Validator & Formatter
Paste YAML to check it instantly: errors are shown with their line and column and the faulty line is highlighted. Then pretty-print it, minify it, sort keys or convert it to JSON. Everything runs in your browser.
Formatting re-writes the data, so comments are not kept in the result. Validation never changes your input.
How to use the YAML Validator & Formatter
- Paste YAML into the editor or press Upload to open a .yaml, .yml or .json file.
- Read the status bar: it says Valid YAML, or shows the line and column of the first error, with the line highlighted in red.
- Press Format YAML to pretty-print with your indent and optional sorted keys, or Minify for compact flow style.
- Convert with YAML → JSON, or paste JSON and press JSON → YAML.
- Copy or download the result from the right-hand box.
The most common YAML errors and how to fix them
| Error message | Typical cause | Fix |
|---|---|---|
| bad indentation of a mapping entry | A key is indented by a different number of spaces than its siblings | Align keys at the same level to exactly the same column |
| end of the stream or a document separator is expected | Text after a value on the same level, often a missing colon or an extra space before a key | Check the line above the reported one for a missing : |
| duplicated mapping key | The same key appears twice in one mapping; most parsers silently keep only the last | Remove or rename one of the keys |
| tab characters must not be used in indentation | The file was indented with tabs | Replace tabs with spaces (2 per level is common) |
| unexpected end of the stream within a double quoted scalar | An opening quote without a closing quote | Close the quote, or escape inner quotes |
| incomplete explicit mapping pair; a key node is missed | A value starting with ?, :, {, [, &, *, !, |, >, @ or % without quotes | Quote the value, for example pattern: "*.log" |
YAML syntax cheat sheet
| Feature | YAML | JSON equivalent |
|---|---|---|
| Mapping | name: app | {"name": "app"} |
| Sequence | - a- b | ["a", "b"] |
| Flow style | {a: 1, b: [x, y]} | {"a": 1, "b": ["x", "y"]} |
| Literal block (keeps line breaks) | script: | line 1 line 2 | "line 1\nline 2\n" |
| Folded block (joins lines) | text: > one two | "one two\n" |
| Anchor and alias | base: &b {x: 1}copy: *b | The aliased value is repeated |
| Null | ~, null or an empty value | null |
| Comment | # note | Not supported in JSON |
| Several documents | --- between documents | An array of documents |
Tips for configuration files
- Quote ambiguous values. Version numbers like
1.10become the number 1.1, and times like22:30may be read as numbers by YAML 1.1 parsers. Write"1.10"and"22:30". - Keep indentation consistent. Pick 2 spaces per level and configure your editor to insert spaces when you press Tab.
- Watch list items under a key. In Kubernetes, Docker Compose and GitHub Actions, both
key:followed by- itemat the same column and indented by two spaces are valid, but mixing the two styles in one file makes mistakes easy. - Validate before you deploy. A syntax check here catches structural errors; tools such as
kubectl apply --dry-run=clientordocker compose configthen check the content against their own schema.
Frequently asked questions
What does the validator check?
It parses the text with js-yaml, a YAML 1.2 parser, and reports syntax errors such as bad indentation, tabs used for indentation, unclosed quotes or brackets, duplicate keys in a mapping and invalid anchors or aliases. It checks that the YAML is well-formed; it does not check it against a schema such as a Kubernetes or GitHub Actions specification.
Why are my comments gone after formatting?
Formatting works by reading the YAML into data and writing it out again, and comments are not part of the data. Use the formatted output when you want a clean, normalised file, and keep the original if the comments matter. Validation never changes your text.
Can I use tabs in YAML?
No. The YAML specification forbids tab characters for indentation; use spaces. Tabs inside quoted strings or after a value are fine. The validator points to the exact line when a tab is used for indentation.
How do I validate a file with several documents?
Separate the documents with a line containing three dashes (---), as in Kubernetes manifests. The validator reads every document, the status bar shows how many it found, and YAML → JSON returns them as a JSON array.
What is the difference between YAML and JSON?
JSON is a strict subset of YAML 1.2 in practice, so most JSON files are also valid YAML. YAML adds comments, indentation-based structure, anchors and aliases for reuse, multi-line strings and several documents per file, which is why it is popular for configuration.
Why did 'no' or 'on' turn into true or false?
Older YAML 1.1 parsers treated yes, no, on and off as booleans (the 'Norway problem', where the country code NO becomes false). js-yaml follows YAML 1.2, where only true and false are booleans, but other tools may differ, so quote such values to be safe.
Is my YAML uploaded?
No. Parsing happens in your browser. The js-yaml library is downloaded once from a public CDN, and your data stays on your device.