Format is part of the prompt
How you structure the context you give a model — not just its content — affects accuracy, token cost, and how reliably the model separates instructions from data. Three formats dominate: JSON, Markdown, and XML-style tags. Each has a sweet spot.
When to use each
| Format | Best for | Weakness |
|---|---|---|
| JSON | Passing structured records, tool results, examples the model should treat as data | Punctuation-heavy; verbose for prose |
| Markdown | Human-readable instructions, headings, lists, documents | Ambiguous boundaries between sections |
| XML-style tags | Clearly delimiting sections and untrusted input | Slightly more tokens than Markdown |
JSON for data, not instructions
JSON is ideal when you are handing the model records it should reason over — API responses, database rows, a list of examples. It signals "this is structured data," and the model handles it well:
Here are the user's recent orders:
[{"id":"A1","total":42,"status":"shipped"},{"id":"A2","total":9,"status":"pending"}]
Which orders still need to ship?Minify this JSON to save tokens — the model does not need indentation.
XML tags for delimiting
Many model providers note that XML-style tags are an effective way to separate parts of a prompt and to fence off untrusted input. The boundaries are unambiguous:
<instructions>
Summarize the document in three bullet points.
</instructions>
<document>
{user-supplied text here}
</document>Because <document> clearly marks data, the model is less likely to follow instructions hidden inside it — a simple defense against prompt injection.
Markdown for instructions
For the instruction portion of a prompt — what you want done, in what style, with what constraints — Markdown is the most natural and readable. Headings and lists map well to how models were trained on human text:
## Task
Rewrite the paragraph for a beginner audience.
## Rules
- Keep it under 100 words
- Avoid jargonA practical hybrid
Real prompts mix all three: Markdown for instructions, XML tags to fence sections, and JSON for the structured data inside a section.
## Task
Classify each review's sentiment.
<reviews>
[{"id":1,"text":"Fast and reliable"},{"id":2,"text":"Broke in a week"}]
</reviews>
Respond with JSON: [{"id":number,"sentiment":"positive"|"negative"}]Tips
- Match output format to consumer. If code consumes the output, demand JSON. If a human reads it, Markdown is friendlier.
- Be consistent. Pick one delimiter style and stick to it across a prompt.
- Fence untrusted input with tags, always.
- Minify data JSON, keep instruction Markdown readable.