intermediateChapter 5 of 12

Formatting Output & Speaking for Claude

Output format control · XML output tags · Response steering

Controlling What Claude Outputs

Sometimes you need Claude's response in a specific format — JSON, a numbered list, XML-wrapped sections, or just a single word. Claude is highly steerable if you're explicit about the desired shape.

XML Output Tags

Just as you use XML tags for input, you can instruct Claude to wrap its output in tags:

Write a haiku about cats. Wrap your response in <poem> tags.

This makes parsing programmatic output much easier.

Multiple Structured Outputs

When you need several distinct pieces, use separate tags:

Analyze this text. Provide:
- A one-sentence summary in <summary> tags
- The overall sentiment in <sentiment> tags
- Three key themes in <themes> tags

A Note on Prefilling (Historical)

Older Claude models supported "prefilling" the assistant response to steer output. Starting with Claude 4.6, this is no longer supported. Instead, use direct instructions and XML output tags — they're more reliable and future-proof.

Key Takeaways

  • Explicitly specify the output format you want.
  • Use XML tags for structured, parseable output.
  • For multiple outputs, assign each a distinct tag.

Exercises