How browsers word it
| PyYAML | yaml.scanner.ScannerError: mapping values are not allowed here |
|---|---|
| js-yaml | YAMLException: bad indentation of a mapping entry |
| Go (yaml.v3) | yaml: mapping values are not allowed in this context |
Common causes
A colon inside a plain value
In plain text a colon followed by a space starts a new key. Put the value in quotes.
Input
title: Note: read this
YAML JSON TOML says
Line 1, column 8: A key can't start on the same line as another key
Two keys on one line
A YAML mapping has one key per line.
Input
a: b: c
YAML JSON TOML says
Line 1, column 4: A key can't start on the same line as another key
A wrongly indented line
A line with more spaces than the one above it looks like part of that value.
Input
key: value bad: x
YAML JSON TOML says
Line 2, column 6: Unexpected ':'. Is a key indented wrongly?
The same value in quotes
Quotes make the colon part of the text.
Input
title: "Note: read this"
YAML JSON TOML says
{"title": "Note: read this"}
How to fix it
- Put values that contain a colon followed by a space, a hash sign or special characters in quotes.
- Give every key its own line, and indent child keys with the same number of spaces.
- Use spaces, not tabs, for indentation.
- Paste the file into the YAML converter: it names the line and column of the problem.