Skip to main content

YAML Validator

Find the line where your YAML breaks

14
Loading editor…

Why YAML errors are hard to see

Structure in YAML comes from leading spaces, which are invisible. Two lines that look aligned can differ by one space or by a tab character, and the parser reports an error on or near the line after the real mistake. Click Validate: the editor jumps to the position the parser reports, and the examples below cover the mistakes that cause most errors.

Common YAML errors and how to fix them

The messages are what this validator shows for each case.

Tab used for indentation

Error: tab characters must not be used in indentation

Invalid

a:
	b: 1

Fixed

a:
  b: 1

YAML forbids tabs for indentation. Replace them with spaces, and set your editor to insert spaces when you press Tab.

Inconsistent indentation

Error: bad indentation of a mapping entry

Invalid

a:
  b: 1
 c: 2

Fixed

a:
  b: 1
  c: 2

Sibling keys must start in the same column. Line 3 is one space short of the keys above it.

Second colon in a plain value

Error: bad indentation of a mapping entry

Invalid

url: http://example.com
title: Note: draft

Fixed

url: http://example.com
title: "Note: draft"

A colon followed by a space starts a new key. Put the value in quotes when it contains ": ".

Duplicate key

Error: duplicated mapping key

Invalid

name: a
name: b

Fixed

name: b

A key may appear once per mapping. Remove one, or rename it if both were meant to exist.

Unclosed quote or bracket

Error: unexpected end of the stream within a double quoted scalar

Invalid

title: "Release notes
version: 2

Fixed

title: "Release notes"
version: 2

The string or list was never closed, so the parser read to the end of the file. The error points at the end of the file, so search upward for the quote or bracket that has no partner.

YAML uses indentation instead of brackets, so a single misplaced space is enough to break a file. This validator parses your YAML and shows the line and column of the first problem. It runs in your browser.

Frequently Asked Questions

Is YAML validated against a schema?

No. The validator checks that the text is well-formed YAML. It cannot know whether the keys and values suit your application, for example a Kubernetes or GitHub Actions file; that needs a schema for that tool.

Why does the error point at the wrong line?

A parser notices a problem when it reads text that no longer fits, which is often the line after the mistake. For unclosed quotes and brackets it can be the end of the file. Look at the lines above the reported one.

Is my YAML uploaded?

No. Parsing happens in your browser, so config files and secrets you paste stay on your device.

Can I convert the YAML to JSON?

Yes. Once it is valid, use the YAML to JSON converter to get the same data as JSON.

Have suggestions or feedback? We're constantly improving FormatChamp based on your comments.