Best Prompt Format: Plain Text vs. Markdown, XML, JSON & YAML

Markdown (.md) is the best universal default for AI prompts, XML tags win for separating long-context documents from instructions, Plain Text wins for quick reasoning queries, and JSON should be reserved for structured outputs rather than input documents.

Most people treat prompt formatting as cosmetic. Research shows it is not. In the Microsoft and MIT benchmark study Does Prompt Formatting Have Any Impact on LLM Performance? (arXiv:2411.10541), keeping the exact same instructions and switching only the structural template between Plain Text, Markdown, YAML, and JSON caused accuracy swings of up to 40% on code translation and 42% on reasoning tasks.

Quick Comparison: Prompt Formats at a Glance

FormatBest Used ForAvoid ForToken Cost
Plain TextQuick 1-shot questions, brainstorming, reasoning models (o3, GPT-5, Gemini Thinking)Multi-document context, strict API schemasLowest
Markdown (.md)Default for instructions, SKILL.md, AGENTS.md, CLAUDE.md, pasted web pagesUntrusted raw text containing conflicting headingsVery Low
XML TagsSeparating instructions, reference documents, and few-shot examples (especially Claude)Short casual chatsLow-Medium
JSONStructured outputs, API extraction, strict typed payloadsLong input documents or prose collectionsHigh
YAMLCompact frontmatter triggers (SKILL.md metadata), flat configsLong multi-paragraph proseLow

1. Plain Text: Best for Fast Reasoning Queries

Modern reasoning models like OpenAI o3, GPT-5, and Gemini Thinking perform chain-of-thought internally. For short, self-contained requests, plain direct English beats bloated templates. State the goal, return format, and constraints in 3 to 5 clear sentences.

2. Markdown (.md): The Best Universal Default

Markdown is the highest-leverage everyday format across ChatGPT, Claude, and Gemini. Headings (#, ##), bullet lists, bold labels, and pipe tables match how frontier models were trained while adding minimal token overhead. When pasting webpages or docs into a chat, strip noisy HTML down to clean Markdown first using tools like Copy Markdown.

3. XML Tags: Best for Long Context & Claude

Anthropic officially recommends XML delimiters (such as <context>, <documents>, <instructions>, and <examples>) because they draw hard boundaries between data and commands. You can invent descriptive tag names, nest multiple documents cleanly, and refer to tag names inside your instructions.

<documents>
  <document index="1">
    <source>q4-report.md</source>
    <content>...</content>
  </document>
</documents>

<instructions>
Identify the top 3 churn drivers cited in <documents>. Quote exact numbers.
</instructions>

4. JSON: Use for Outputs, Not Document Inputs

OpenAI's GPT-4.1 prompting guide explicitly notes that JSON performs poorly for feeding collections of documents into a prompt. Escaped quotes, braces, and nested brackets burn extra tokens and reduce retrieval accuracy. Reserve JSON for defining the output schema when integrating with software pipelines.

5. YAML: Best for Skill Triggers & Compact Metadata

YAML uses 20% to 30% fewer tokens than JSON for key-value structures. That is why Claude Skills and Agent Skills use YAML frontmatter at the top of SKILL.md to declare lightweight discovery triggers (~100 tokens) before loading full Markdown instructions.

Frequently Asked Questions

Does prompt format really change AI accuracy?

Yes. Academic testing (arXiv:2411.10541) demonstrated up to 40% to 42% accuracy variance on identical prompts simply by switching between Plain Text, Markdown, YAML, and JSON. Larger frontier models are more resilient, but clear boundaries still measurably reduce drift.

Should I use Markdown or XML tags for Claude?

Use Markdown for simple prompts and documents, and wrap distinct sections (reference docs, examples, output rules) in XML tags whenever your prompt mixes source data with instructions.

Why should I avoid JSON for input documents?

JSON requires quotes, braces, and escaped newlines that inflate token counts and obscure natural document hierarchy. Pass documents in Markdown or XML, and request JSON only when your application needs a structured output payload.

← Back to All Articles