$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:
- Documentation: Explain complex schema logic or constraints
- Maintenance Notes: Leave reminders or warnings for future maintainers
- Tooling Directives: Provide instructions to linters, formatters, or other tools
- 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
"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
$commentvalues - Convert
$commentvalues to native comments - Preserve both native comments and
$commentvalues
$comment are present, translation behavior is implementation-dependent:
Best Practices
Use Description for User-Facing Text
Usedescription 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
Related Keywords
description- User-facing documentation (produces annotations)title- Short schema title (produces annotations)examples- Example valid instances (produces annotations)