Browse
2 min read

How to use XML tags in Claude prompts

Wrapping parts of your prompt in simple tags is one of the easiest ways to get more reliable answers from Claude. A practical guide with examples.

If you look closely at the prompts on this site, you will notice small tags like <draft> and <notes> around the text you paste in. They are not decoration. Anthropic's own prompting guidance recommends XML-style tags for structuring prompts, and in practice it is one of the simplest habits that makes answers more reliable.

What the tags do

A prompt usually mixes two things: your instructions, and material you want Claude to work on. When both are plain paragraphs, the line between them is blurry. Does "make it shorter" belong to your instructions, or is it part of the email you pasted?

Tags remove the doubt:

Summarise the customer email below in two sentences, then draft a reply.

<email>
Hi, I ordered the blue lamp three weeks ago and...
</email>

Now there is no way to confuse the email with the task.

There are no magic tag names

Claude has no special list of tags. <email>, <contract>, <my_notes> all work. Pick names that describe the content, and use the same names when you refer to them: "Using the figures in <report>, answer the question in <question>."

Four places where tags help the most

1. Long pasted material. Documents, transcripts, code, data. Put each one in its own tag. If there are several, give them different names or add a number.

2. Examples. Wrap sample outputs in <example> tags and say what to copy from them: "Match the tone of the example, not its content."

3. Keeping rules apart from context. Background goes in one block and rules in another. When you reuse the prompt next month, you only edit the block that changed.

4. Asking for a structured answer. You can ask Claude to use tags in its reply: "Put your reasoning in <thinking> tags and the final email in <email> tags." That makes the useful part easy to find, and easy to extract if you are working with code.

A full example

You are a careful contract reviewer.

<contract>
[PASTE THE CONTRACT]
</contract>

<concerns>
We are a small agency. We care most about payment terms,
who owns the work, and how either side can end the agreement.
</concerns>

List every clause that touches our concerns. Quote it, explain
it in plain language, and rate the risk as low, medium or high.
If the contract says nothing about one of our concerns, say so.

Common mistakes

  • Forgetting to close a tag. Always add the closing </contract>.
  • Tagging everything. A three line prompt does not need structure. Use tags when there is pasted material or when there are several distinct parts.
  • Nesting too deep. One level is usually enough. Two at most.

Try it

Pick any prompt from the collection and look at how the tags separate your material from the instructions. Then add a pair of tags to the next long prompt you write, and compare the answers.

Put it into practice with these prompts

All prompts
Video outputAn animated chart building up a comparison of two bars over a few seconds, with a counter ticking up to the final figure and a caption stating the finding

Animate a number so people feel it

Give Claude one statistic and its context, and get a short animated visual in HTML that builds the number up step by step instead of just showing it.

Text output

Prices Fact Detail Source Unit price EUR 4.20 per unit for the first 10,000 units Section 3.1, "Pricing" Volume discount EUR 3.85 per unit above 10,000 units in a calendar year Section 3.1, "Pricing" Setup fee EUR 1,500...

Pull the facts out of this document

Turn a long report, contract or transcript into a structured list of facts, numbers and dates, each with a pointer back to where it came from.

Image outputA bar chart of monthly newsletter signups from January to December, with the launch month highlighted and labelled

Turn a CSV into a clean chart

Paste raw CSV and get a clean SVG chart with sensible scales, labels on the data, and a title that says what the chart shows.

Keep reading

All articles
2 min read

How the weekly ranking works

One vote per prompt, a fresh count every Monday, and a simple tie-break. Everything about how prompts reach the top three, in plain words.