Different formats perform differently under different conditions. This is not a matter of opinion — multiple controlled tests and official documentation provide concrete data.
Markdown headings and formatting (like ## Instructions, ## Context, bullet lists, and bold for emphasis) are readable, token-efficient, and naturally understood by models trained on documentation .
Accuracy advantage: On reasoning tasks, GPT-4 achieved 81.2% accuracy with Markdown-structured prompts compared to 73.9% with JSON — a 7.3 percentage point improvement . Markdown also uses about 15% fewer tokens than JSON while maintaining clarity .
Human-friendly: Markdown is commonly recommended for making prompts and instruction files clearer for both humans and AI models . OpenAI's own Playground suggests Markdown with H1 headings for prompt generation .
The main drawback: Markdown headings are softer boundaries. They can be more vulnerable to prompt injection because the model may not treat ## Input as a hard delimiter . One security researcher specifically discouraged using Markdown for delimiting input that needs to be classified, noting that the model is "less likely to get tricked" by XML tags .
XML-style tags use explicit open-close markers like <instructions>, <schema>, and <input> to separate prompt sections. Anthropic's official guidance explicitly recommends XML tags as the primary structural tool for complex prompts, noting that they create unambiguous boundaries that reduce misinterpretation .
Security advantage: XML provides explicit open-close boundaries, which makes it harder for injected content to bleed between sections . For AI agents, guidance argues that XML tags outperform Markdown headers for separating instructions, examples, reference data, and user questions .
Not always better: For short, simple prompts, XML can actually slightly reduce accuracy. One test showed flat prompts at 97.6% accuracy versus XML at 96.4% — a small 1.2 percentage point penalty with no change in hallucination rate . The same test showed a 31% increase in input token overhead with XML . The benefit of XML scales with prompt complexity, not prompt quality: it helps when the prompt exceeds roughly 500 tokens with 3 or more logical sections .
| Provider | Recommendation |
|---|---|
| Anthropic (Claude) | Explicitly recommends XML tags for complex prompts; XML-style tags as primary structural tool |
| OpenAI (GPT) | Suggests Markdown with H1 headings in Playground; XML also works when strict boundaries matter |
| General industry guidance | XML recommended for complex/multi-section prompts and safety-critical tasks; Markdown for readability |
All three major vendors recommend XML as an effective delimiter pattern, but the formality of the XML doesn't need to be strict — the semantic intent is what matters .
| Use Case | Recommended Format |
|---|---|
| Short, simple prompts | Markdown or plain text |
| Complex multi-section prompts | XML tags for section separation |
| Anthropic Claude prompts | XML tags, since Anthropic explicitly recommends them |
| OpenAI GPT prompts | Markdown headers commonly recommended; XML also helpful when strict boundaries matter |
| High-security / prompt-injection-sensitive | XML tags, because explicit open-close boundaries are harder to trick |
| Human-readable shared documentation | Markdown |
| Production agent pipelines | XML-style tags for clearer section boundaries |
Many practitioners use a hybrid: Markdown headings for overall structure plus XML-style tags or code fences around user input blocks . This approach combines the readability of Markdown with the security boundaries of XML.
For example, you might use:
## Instructions
[Your instructions here]
## Context
[Background information]
## User Input
<UserInput>
[actual user input]
</UserInput>
This pattern gives you the best of both worlds — clear labeled sections that are easy for humans to read, plus hard boundaries around the untrusted part of the prompt.
Use Markdown for most day-to-day prompting because it is readable, token-efficient, and performs well in documented prompt-format comparisons . Switch to XML tags when you have complex, multi-part prompts, need hard semantic boundaries for security, or are working with Claude . The effectiveness of the format also depends on the AI model — maintainability on the human side matters just as much as model performance .
Different formats perform differently under different conditions. This is not a matter of opinion — multiple controlled tests and official documentation provide concrete data.
Markdown headings and formatting (like ## Instructions, ## Context, bullet lists, and bold for emphasis) are readable, token-efficient, and naturally understood by models trained on documentation .
Accuracy advantage: On reasoning tasks, GPT-4 achieved 81.2% accuracy with Markdown-structured prompts compared to 73.9% with JSON — a 7.3 percentage point improvement . Markdown also uses about 15% fewer tokens than JSON while maintaining clarity .
Human-friendly: Markdown is commonly recommended for making prompts and instruction files clearer for both humans and AI models . OpenAI's own Playground suggests Markdown with H1 headings for prompt generation .
The main drawback: Markdown headings are softer boundaries. They can be more vulnerable to prompt injection because the model may not treat ## Input as a hard delimiter . One security researcher specifically discouraged using Markdown for delimiting input that needs to be classified, noting that the model is "less likely to get tricked" by XML tags .
XML-style tags use explicit open-close markers like <instructions>, <schema>, and <input> to separate prompt sections. Anthropic's official guidance explicitly recommends XML tags as the primary structural tool for complex prompts, noting that they create unambiguous boundaries that reduce misinterpretation .
Security advantage: XML provides explicit open-close boundaries, which makes it harder for injected content to bleed between sections . For AI agents, guidance argues that XML tags outperform Markdown headers for separating instructions, examples, reference data, and user questions .
Not always better: For short, simple prompts, XML can actually slightly reduce accuracy. One test showed flat prompts at 97.6% accuracy versus XML at 96.4% — a small 1.2 percentage point penalty with no change in hallucination rate . The same test showed a 31% increase in input token overhead with XML . The benefit of XML scales with prompt complexity, not prompt quality: it helps when the prompt exceeds roughly 500 tokens with 3 or more logical sections .
| Provider | Recommendation |
|---|---|
| Anthropic (Claude) | Explicitly recommends XML tags for complex prompts; XML-style tags as primary structural tool |
| OpenAI (GPT) | Suggests Markdown with H1 headings in Playground; XML also works when strict boundaries matter |
| General industry guidance | XML recommended for complex/multi-section prompts and safety-critical tasks; Markdown for readability |
All three major vendors recommend XML as an effective delimiter pattern, but the formality of the XML doesn't need to be strict — the semantic intent is what matters .
| Use Case | Recommended Format |
|---|---|
| Short, simple prompts | Markdown or plain text |
| Complex multi-section prompts | XML tags for section separation |
| Anthropic Claude prompts | XML tags, since Anthropic explicitly recommends them |
| OpenAI GPT prompts | Markdown headers commonly recommended; XML also helpful when strict boundaries matter |
| High-security / prompt-injection-sensitive | XML tags, because explicit open-close boundaries are harder to trick |
| Human-readable shared documentation | Markdown |
| Production agent pipelines | XML-style tags for clearer section boundaries |
Many practitioners use a hybrid: Markdown headings for overall structure plus XML-style tags or code fences around user input blocks . This approach combines the readability of Markdown with the security boundaries of XML.
For example, you might use:
## Instructions
[Your instructions here]
## Context
[Background information]
## User Input
<UserInput>
[actual user input]
</UserInput>
This pattern gives you the best of both worlds — clear labeled sections that are easy for humans to read, plus hard boundaries around the untrusted part of the prompt.
Use Markdown for most day-to-day prompting because it is readable, token-efficient, and performs well in documented prompt-format comparisons . Switch to XML tags when you have complex, multi-part prompts, need hard semantic boundaries for security, or are working with Claude . The effectiveness of the format also depends on the AI model — maintainability on the human side matters just as much as model performance .