Skip to main content
The $comment keyword reserves a location for comments from schema authors to readers or maintainers of the schema. It has no effect on validation or annotation collection.

Syntax

string
required
A string containing comments, notes, or directives for humans or developer tooling.

Purpose

The $comment keyword enables:
  1. Documentation: Explain complex schema logic or constraints
  2. Maintenance Notes: Leave reminders or warnings for future maintainers
  3. Tooling Directives: Provide instructions to linters, formatters, or other tools
  4. Decision Rationale: Document why certain design choices were made

Usage

Basic Documentation

Explaining Complex Logic

Examples

Maintenance Notes

Tooling Directives

Design Rationale

Temporary Notes

Multi-line Comments

Validation and Annotation Behavior

The $comment keyword:
  • MUST NOT affect validation results
  • MUST NOT be collected as an annotation
  • MUST NOT influence the evaluation of any other keywords
Instances are validated against "type": "string" only. The comment has no effect.

Tooling Integration

Linter Directives

Tools may use $comment values as directives:

Code Generation Hints

Documentation Extraction

Documentation generators might extract $comment values:

Translation Considerations

Tools that translate schemas between formats or programming languages MAY:
  • Convert native comments to $comment values
  • Convert $comment values to native comments
  • Preserve both native comments and $comment values
When both native comments and $comment are present, translation behavior is implementation-dependent:
Implementations should document how they handle this scenario.

Best Practices

Use Description for User-Facing Text

Use description for documentation intended for schema users, and $comment for internal notes:

Keep Comments Concise

While multi-line comments are supported, keep them focused:

Use Structured Comment Formats

For tooling integration, consider structured formats:

Comparison with Description

  • description - User-facing documentation (produces annotations)
  • title - Short schema title (produces annotations)
  • examples - Example valid instances (produces annotations)