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
  1. Full-line commentThe parser ignores the whole line.
  2. Inline commentEverything after the value is ignored.
  3. Quoted literal#release remains part of the string.
  4. 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 #

Comment, not data
tag: #release
Literal data
tag: "#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 content

Expected 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.

Continue in YAML Formatter →