XML vs Markdown Prompts: How to Format One Prompt for Claude, GPT and Gemini

Updated November 2026 against each vendor's current prompting docs.
The question of XML vs markdown prompts has a documented answer for each vendor. Anthropic says XML tags "help Claude parse complex prompts unambiguously" (Anthropic, Prompting best practices). Google says "XML-style tags (e.g., <context>, <task>) or Markdown headings are effective" and asks you to "choose one format and use it consistently within a single prompt" (Google, Prompt design strategies). OpenAI's guidance is to keep the prompt short and put the output schema in the API instead (OpenAI, Using GPT-5.5).
A prompt that works well on one model is a good starting point on another, and it still needs a test run there before you rely on it. Use the same delimiters when you write a system prompt.
Does Prompt Format Change Results?
Format does change results. A 2024 study put the same content into plain text, Markdown, JSON and YAML templates and found GPT-3.5-turbo's score varied by up to 40% on a code translation task, while larger models such as GPT-4 were more robust (He et al., 2024). The practical reading: format matters most on smaller models, and the safe default on any model is clear, consistent delimiters.
Each vendor documents a preference. Anthropic's documentation recommends XML tags for separating the parts of a prompt. OpenAI puts JSON schema enforcement in the API with Structured Outputs. Google's guide says XML-style tags or Markdown headings both work, as long as you use one style per prompt.
Same Task, Three Formats
Here's the practical difference. Take a common task: extracting structured data from a messy product description. Same input, same desired output, three different prompt architectures.
Claude: XML Tags
Anthropic recommends XML tags for keeping instructions, data and format apart, and says they "help Claude parse complex prompts unambiguously". Say exactly what you want. Wording like "try to" or "if possible" leaves the model to guess how hard to try.
The Prompt:
<task>
Extract product attributes from the description below.
Return exactly the fields specified in the output format.
If a field cannot be determined from the text, use null.
</task>
<input>
SuperGlow 3000 LED panel, 24 watts, 3500K warm white,
dimmable, works with Alexa and HomeKit, rated for damp
locations, 5-year warranty, replaces 150W incandescent
</input>
<output_format>
{
"name": "string",
"wattage": "number or null",
"color_temp_kelvin": "number or null",
"dimmable": "boolean",
"smart_home": ["string"],
"warranty_years": "number or null",
"equivalent_wattage": "number or null"
}
</output_format>
<rules>
- Do not infer attributes not stated in the input
- Smart home platforms must be listed individually
- Return only the JSON object, no commentary
</rules>
Why This Works:
The XML tags split the prompt into four labelled parts. <task> sets intent, <input> isolates data, <output_format> defines the contract, and <rules> adds constraints. The explicit "use null" instruction removes a guess. If you need a guarantee rather than an instruction, Claude's API also supports structured outputs, which "guarantee schema-compliant responses through constrained decoding" (Anthropic, Structured outputs).
Expected Output:
{ "name": "SuperGlow 3000 LED panel", "wattage": 24, "color_temp_kelvin": 3500, "dimmable": true, "smart_home": ["Alexa", "HomeKit"], "warranty_years": 5, "equivalent_wattage": 150 }
GPT: Schema in the API, Not the Prompt
OpenAI's migration checklist says to "remove output schema definitions from the prompt where possible" and validate with Structured Outputs (OpenAI, Using GPT-5.5). Structured output explains the API-level options. The json_schema mode enforces schema adherence as well as valid JSON syntax. The prompt gets shorter because the schema does the structural work.
The Prompt:
Extract product attributes from this description. If an
attribute cannot be determined, use null.
Description: SuperGlow 3000 LED panel, 24 watts, 3500K warm
white, dimmable, works with Alexa and HomeKit, rated for damp
locations, 5-year warranty, replaces 150W incandescent
API Configuration (the other half of the prompt):
{
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "product_attributes",
"strict": true,
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"wattage": { "type": ["number", "null"] },
"color_temp_kelvin": { "type": ["number", "null"] },
"dimmable": { "type": "boolean" },
"smart_home": {
"type": "array",
"items": { "type": "string" }
},
"warranty_years": { "type": ["number", "null"] },
"equivalent_wattage": { "type": ["number", "null"] }
},
"required": ["name", "wattage", "color_temp_kelvin",
"dimmable", "smart_home", "warranty_years",
"equivalent_wattage"],
"additionalProperties": false
}
}
}
}
Why This Works:
Structured Outputs "constrains completed, non-refusal model output to your supplied JSON Schema" (OpenAI, Structured Outputs). Note the exception: a refusal is not schema-shaped, so your code still needs to handle it. Your prompt text focuses on the task and the input, and the schema handles the output contract at a layer below the text. Legacy JSON mode (just "type": "json_object") only guarantees valid JSON syntax, not schema conformance. That distinction matters.
Expected Output:
Identical JSON structure to the Claude example, but the guarantee is different: with the schema in the API, the shape is enforced by the platform, on OpenAI's Structured Outputs or Claude's structured outputs. With the schema only in the prompt, the model follows it because it was told to.
For the API side of this, see structured output prompting and why XML tags help.
Gemini: Pick One Delimiter Style and Keep It
Google's guide accepts XML-style tags or Markdown headings and asks for one style per prompt.
The Prompt:
## Task
Extract product attributes from the description below.
Use null for any attribute not explicitly stated.
## Input
SuperGlow 3000 LED panel, 24 watts, 3500K warm white,
dimmable, works with Alexa and HomeKit, rated for damp
locations, 5-year warranty, replaces 150W incandescent
## Output Fields
| Field | Type | Notes |
|---|---|---|
| name | string | Full product name |
| wattage | number or null | Actual wattage |
| color_temp_kelvin | number or null | In Kelvin |
| dimmable | boolean | |
| smart_home | string[] | List each platform |
| warranty_years | number or null | |
| equivalent_wattage | number or null | Incandescent equivalent |
## Rules
- Do not infer attributes not stated in the input
- Return only the JSON object
Why This Works: The markdown headings split the prompt into labelled sections, and the table puts every output field in one place.
Expected Output:
Same JSON structure. If the output feeds code, set a JSON Schema in the API as well (Google, Structured output).
Reasoning Effort Replaces "Think Step by Step"
If your prompts still include "think step by step" or "reason carefully before answering", a reasoning model's API setting is now the better place to control that.
Current reasoning models from all three vendors expose a reasoning setting in the API. Anthropic's effort guidance for Claude Opus 4.7 says that if you see shallow reasoning on complex problems, you should "raise effort rather than prompting around it". Its general advice for every model is to "Test your use case" (Anthropic, Effort).
Each vendor names the setting differently, and the allowed values depend on the model. Anthropic uses output_config.effort, with levels from low to max (not every model supports every level) (Anthropic, Effort). OpenAI uses reasoning.effort, whose values "can include none, minimal, low, medium, high, xhigh, and max" depending on the model (OpenAI, Reasoning models). Google uses thinking_level, with values from minimal to xhigh depending on the model (Google, Thinking). Check the model's page before you pick a level. More in our guide to reasoning effort.
The practical lesson: remove reasoning scaffolding from your prompt text and control it through the API setting instead, then compare both versions on your own inputs.
Format Helps You Validate
Structured formats don't stop a model from being wrong, but they make wrong answers easier to catch. A schema rejects invented fields, and an explicit null rule reduces guessed values. Pair them with a verification step for anything a person relies on.
Quick Reference
| Claude | GPT | Gemini | |
|---|---|---|---|
| Structure | XML tags | Concise prose + JSON schema via API | XML-style tags or Markdown headings, one style per prompt |
| Reasoning control | output_config.effort (levels vary by model; Anthropic, Effort) |
reasoning.effort (values vary by model) |
thinking_level (values vary by model) |
| Output format | Structured outputs (output_config.format, json_schema) |
Structured Outputs (json_schema) | JSON Schema in the API (response_format) |
| Avoid | Vague hedges, "if possible" | Describing schemas in prompt text | Over-constraining before reasoning |
Start Here
Pick one prompt you use regularly. Rewrite it three ways using the patterns above. Run the same input through all three and compare. Note where the outputs differ, and keep the version that does best on your inputs.
Prompting still matters, and part of the structure now lives in the API. Write each prompt with clear, consistent delimiters, move schemas into the API where you can, and test on each model you ship to.
More in Techniques.
If your team wants hands-on training on model-specific prompting and effort routing, connect with Kief Studio on Discord or schedule a session.
Frequently asked questions
Should I use XML or Markdown in my prompts?
Either works if you're consistent. Anthropic recommends XML tags for Claude because they "help Claude parse complex prompts unambiguously" (Anthropic). Google says XML-style tags or Markdown headings are effective and asks you to use one format within a prompt (Google).
Do XML tag names matter?
Not in a fixed way. Anthropic's guidance is to use "consistent, descriptive tag names across your prompts" and to nest tags where content has a natural hierarchy (Anthropic).
How do I get reliable JSON from an LLM?
Use the API's schema feature rather than describing the schema in prose. OpenAI's Structured Outputs constrains output to your JSON Schema, apart from refusals (OpenAI), and Claude's structured outputs use constrained decoding to guarantee schema-compliant responses (Anthropic).
Does prompt format really change results?
It can. One study found GPT-3.5-turbo's results varied by up to 40% on a code translation task depending only on the template, while GPT-4 was more robust (He et al., 2024). Test your own prompt in the format you plan to ship.
Terms in this article
From the library
Rather have someone set it up for you?
That's a fair call. LTFI, the agentic business operating system from Kief Studio, can set up the work these guides describe and run it with you. No website yet? Kief Studio will build you one for free.

