Home › Developer Tools › YAML Validator & Formatter

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.

Loading the YAML engine…

Formatting re-writes the data, so comments are not kept in the result. Validation never changes your input.

Advertisement
Advertisement

How to use the YAML Validator & Formatter

  1. Paste YAML into the editor or press Upload to open a .yaml, .yml or .json file.
  2. Read the status bar: it says Valid YAML, or shows the line and column of the first error, with the line highlighted in red.
  3. Press Format YAML to pretty-print with your indent and optional sorted keys, or Minify for compact flow style.
  4. Convert with YAML → JSON, or paste JSON and press JSON → YAML.
  5. Copy or download the result from the right-hand box.

The most common YAML errors and how to fix them

Error messageTypical causeFix
bad indentation of a mapping entryA key is indented by a different number of spaces than its siblingsAlign keys at the same level to exactly the same column
end of the stream or a document separator is expectedText after a value on the same level, often a missing colon or an extra space before a keyCheck the line above the reported one for a missing :
duplicated mapping keyThe same key appears twice in one mapping; most parsers silently keep only the lastRemove or rename one of the keys
tab characters must not be used in indentationThe file was indented with tabsReplace tabs with spaces (2 per level is common)
unexpected end of the stream within a double quoted scalarAn opening quote without a closing quoteClose the quote, or escape inner quotes
incomplete explicit mapping pair; a key node is missedA value starting with ?, :, {, [, &, *, !, |, >, @ or % without quotesQuote the value, for example pattern: "*.log"

YAML syntax cheat sheet

FeatureYAMLJSON equivalent
Mappingname: 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 aliasbase: &b {x: 1}
copy: *b
The aliased value is repeated
Null~, null or an empty valuenull
Comment# noteNot supported in JSON
Several documents--- between documentsAn array of documents

Tips for configuration files

  • Quote ambiguous values. Version numbers like 1.10 become the number 1.1, and times like 22:30 may 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 - item at 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=client or docker compose config then 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.

Related tools