YAML & Config
YAML Comments
YAML comments start with # outside quoted values. Use them to explain intent, not to duplicate an obvious key name.
Published
Annotated YAML
Four meanings of # in one example
Labels make the parser boundary explicit; color is only a supporting cue.
# full-line comment
service:
port: 8080 # inline comment
tag: "#release"
message: |
# this is scalar content- Full-line commentThe parser ignores the whole line.
- Inline commentEverything after the value is ignored.
- Quoted literal#release remains part of the string.
- Block scalar contentThe indented # belongs to message.
Parsed data
What becomes part of the value?
Of these four # cases, the quoted # and the # inside the block scalar are data. The full-line and inline # segments are comments.
Common failure
Quote a value that starts with #
tag: #releasetag: "#release"Edit annotated YAML
Full-line and inline comments
Comments explain a setting without becoming part of its value.
# Production settings
port: 8080 # Public HTTP port
label: "build #42"
message: |
# This line is scalar contentExpected result: Valid YAML; the quoted and block-scalar hash characters remain data.
Practice with the full tool
Check your YAML configuration
Use your own configuration and verify comments, quoted values and syntax in YAML Formatter.