Why Claude Prefers XML Over JSON
Anthropic, the creators of Claude, have officially documented that Claude performs significantly better at role-playing and structured data extraction when the data is wrapped in XML tags. While GPT-4 prefers JSON, Claude was trained on a massive corpus of XML documents, making it much better at following "tag-based" instructions.
Maximum Performance for Prompting
If you are building a complex RAG system or a prompt that requires Claude to extract information from a table, wrapping that table in <data> and <record> tags is the proven way to reduce errors.
Frequently Asked Questions
Does Claude really work better with XML?
Yes. Anthropic's documentation recommends using XML tags to separate instructions from data for the best results with Claude 3.5 Sonnet.
Can I customize the record tags?
The tool uses a standard <records> wrapper with individual <item> tags for each row, which is the most widely compatible structure for LLM parsing.