<format> — when and how to use it in Claude prompts
Use to describe a schema, a JSON shape, or a free-form style requirement.
Describes the required shape of the output — a schema, a JSON skeleton, a style spec.
When to use <format>
- Constraining Claude to a specific output structure when prose instructions alone aren't enough.
- Documenting a JSON or XML response shape inline.
When not to use it
- When you're using Claude's native tool-use / JSON mode via the API — let those features enforce structure.
Minimal example
<format>
{
"sentiment": "positive|neutral|negative",
"confidence": 0.0
}
</format>
Full example
<instructions>
Analyze the review and return JSON matching the shape in <format>.
Return only the JSON object — no prose, no markdown fences.
</instructions>
<format>
{
"sentiment": "positive | neutral | negative",
"confidence": 0.0,
"keywords": ["string"],
"would_recommend": true
}
</format>
<review>{{ user_review }}</review>
Common mistakes
- Describing the format in prose and also showing a schema — pick one. Two specs invite disagreement.
- Forgetting to tell Claude "return only the JSON" — by default it may wrap in
```jsonfences.
Cite this page
<format> — When and How to Use in Claude Prompts. claudexml.com. https://claudexml.com/tags/format/