Xerobit

YAML Lint: Check YAML Syntax Instantly

Paste your YAML to run a yaml lint check. It reports the first syntax error with its line and column, including bad indentation, tabs, unclosed quotes or brackets, undefined aliases and duplicate keys. Everything runs in your browser and nothing is uploaded.

Paste a YAML file or snippet. Multiple documents separated by --- are supported.

Result

Valid YAML (empty input).

By · Published · How we build and test tools

How to use the yaml lint

  1. Paste or type your YAML into the YAML input field.
  2. The yaml lint check runs automatically as you type.
  3. Read the result area for a success message or a list of errors with line numbers.
  4. Fix the reported issues in your source file and paste again to re-check.

What this yaml lint checks

This yaml lint tool parses your text with a hand-written parser that follows the YAML 1.2 rules for the constructs real files use. It stops at the first problem and reports the line number, the column and a plain-English reason, so you can fix it and run the check again.

Parsing happens locally in your browser. Nothing leaves your machine, which makes it safe to check configuration files that contain internal hostnames or secrets. Inputs up to 1,000,000 characters are accepted.

Supported YAML features

The parser understands the syntax found in Docker Compose files, GitHub Actions workflows, Kubernetes manifests and OpenAPI documents:

  • Block mappings and sequences, including a sequence written at the same indentation as its parent key.
  • Flow collections such as [1, 2, 3] and {a: 1, b: 2}, even when they span several lines.
  • Scalars in plain, single-quoted and double-quoted form, with escape checking for double quotes, plus multi-line plain and quoted scalars.
  • Block scalars introduced by | or > with optional indentation digit and + or - chomping indicators.
  • Anchors, aliases and merge keys (&base, *base, <<), tags such as !!str, and explicit ? key entries.
  • Multiple documents separated by --- and ..., and %YAML or %TAG directives.
  • Comments starting with #.

If you want to reformat a file after it passes, use the yaml formatter.

Errors this linter reports

The most common failures in real files are listed below, with the message you will see.

  • Bad indentation: a line that does not line up with its siblings, or text indented under a value that cannot hold children.
  • Tabs: YAML forbids tab characters for indentation. Use spaces only.
  • A colon inside a plain value: title: Note: remember is rejected with "Mapping values are not allowed here". Quote the value to fix it.
  • Unclosed quotes and brackets: a missing closing ", ', ] or }.
  • Undefined aliases: *name used before a matching &name anchor exists in the same document.
  • Duplicate keys: the same key twice in one mapping. The spec requires keys to be unique, and most parsers silently keep only the last value.
  • Bad escapes: an unknown backslash sequence such as \q, or a \u escape without four hex digits.

Quoting rules that trip people up

A plain scalar cannot contain a colon followed by a space or a space followed by a hash, because those start a mapping value or a comment. A value like url: http://example.com is fine because the colon is not followed by a space, but note: see: below is an error. Wrapping the text in quotes always resolves the ambiguity: note: "see: below".

A plain value also cannot begin with a character that has a special meaning, including @, a backtick or %. Words such as yes, no and on are valid syntax, but some parsers turn them into booleans, so quote them when you mean text.

Two valid-looking mistakes survive a syntax check: a wrong indentation that still parses (for example a key nested one level too deep) and a typo in a key name. A linter only proves that the file is well formed, not that it matches the schema your application expects.

Reference: quick syntax patterns

PatternExampleNotes
Mappingkey: valueSpace after the colon is required
Sequence- itemDash followed by a space
Flow array[1, 2, 3]Comma-separated inside brackets
Flow map{a: 1, b: 2}Comma-separated pairs inside braces
Literal blockkey: |Keeps line breaks
Folded blockkey: >Folds single line breaks into spaces
Anchor and alias&a and *aThe anchor must come first
Double-quoted"tab\there"Supports escape sequences
Single-quoted'it''s'Escape a quote by doubling it

Limits and differences from other parsers

This checker validates syntax only. It does not convert types, so it will not tell you that 12:30 becomes a number in YAML 1.1 parsers or that a date-like string becomes a timestamp.

It follows the YAML 1.2 specification. A few libyaml-based tools, including PyYAML, are stricter in corner cases, for example by rejecting {a:{b: 1}} without a space after the colon, or by requiring --- before a document that follows .... Flow collections used as mapping keys are reported as unsupported rather than guessed at. For anything beyond a syntax check, such as converting the data, use the yaml to json converter.

Worked examples

ExampleInputResult
Valid mappingYAML input: name: Alice / age: 30 / tags: [admin, dev]Status: Valid; Documents: 1; Top level: mapping
Bad indentationYAML input: server: / host: localhost / port: 8080Status: Invalid; Error line: 3
Anchors and merge keyYAML input: base: &base / retries: 3 / timeout: 10 / prod: / <<: *base / timeout: 30Status: Valid; Documents: 1; Top level: mapping; Anchors / aliases: 1 / 1
Block scalarYAML input: bio: | / Line one / Line twoStatus: Valid; Documents: 1; Top level: mapping
Colon in a valueYAML input: title: Note: remember thisStatus: Invalid; Error line: 1

FAQ

What does a yaml lint tool do?

It reads your YAML text and checks that the syntax follows the YAML rules. When it finds a problem it reports the line, the column and a description of the error.

Is my data sent to a server?

No. The entire check runs in your browser using JavaScript. Nothing is uploaded anywhere.

Does this linter support anchors and aliases?

Yes. Anchors, aliases, merge keys and tags are parsed. An alias that points to an anchor that has not been defined earlier in the same document is reported as an error.

Can I check multiple YAML documents at once?

Yes. Documents separated by --- (and optionally ...) are each checked, and the result card shows how many documents were found.

How do I fix indentation errors?

Use spaces instead of tabs and make sure every key at the same level starts in the same column. Each nested level must be indented further than its parent, and two spaces per level is the usual convention.

Why is a colon in my value an error?

A colon followed by a space inside an unquoted value looks like the start of another key. Wrap the value in single or double quotes, for example title: "Note: remember this".

Does it stop at the first error?

Yes. It reports the first problem it finds. Fix it and run the check again, because later lines are often fine once the first mistake is corrected.

Does this replace a full YAML library?

No. It is designed for quick syntax checks. To convert or process the data, use a library or a tool such as the yaml to json converter.