Prompt to XML Formatter

Convert plain prompts to Claude-style XML-tagged prompt structure

Paste a free-text prompt and get it wrapped in semantic XML tags — instructions, context, examples, and output_format — following Anthropic's recommended structure for Claude. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

Why use XML tags in prompts?

Anthropic recommends XML-style tags because Claude is trained to recognise them as clear section boundaries. Tags reduce ambiguity about where context ends and instructions begin, which improves reliability on multi-part prompts.

Prompt to XML formatter

Anthropic’s prompting guidance recommends wrapping the parts of a prompt in XML-style tags<instructions>, <context>, <examples>, <output_format> — because Claude is trained to treat them as clean section boundaries. This tool takes a plain-text prompt and does that wrapping for you, detecting likely sections from headings and keywords so you start from a structured draft instead of a wall of text.

How it works

The formatter splits your prompt into blocks on blank lines and headings, then classifies each block:

  • blocks mentioning “example”, “e.g.”, or input/output pairs become <examples>,
  • blocks mentioning “format”, “respond with”, or “output” become <output_format>,
  • background or reference material becomes <context>,
  • everything imperative defaults to <instructions>.

You can switch to a custom tag style if your team uses different names. The output is indented, valid XML you can paste straight into a Claude prompt. Because detection is heuristic, treat the result as a first pass — re-tag any block the parser misread.

Why XML tags improve Claude performance specifically

The reason XML tags work better with Claude than with most other models comes down to training. Claude is trained with XML-structured prompts as a primary format, so the model has strong priors about what each tag means and where the boundaries between sections lie. When a prompt uses <instructions> and <context> tags, Claude processes them as semantically distinct regions, which reduces the risk of the model conflating background context with actionable instructions.

The practical effect is most noticeable in multi-part prompts where several things are happening at once: here is the background, here is what I want you to do, here is an example of the output, and here is the format to follow. Without tags, these sections blur into each other and the model has to infer the structure. With tags, the structure is explicit.

The standard tag vocabulary

Anthropic’s recommended prompt structure uses these core tags:

TagPurpose
<instructions>The imperative task description — what to do
<context>Background information the model needs to understand the task
<examples>One or more input/output demonstrations of the desired behaviour
<output_format>Explicit format requirements — JSON schema, length, structure
<user_input>The user-supplied content when separating it from instructions
<thinking>(Claude 3 extended thinking) Marks where scratchpad reasoning goes

Custom tag names work equally well — the model treats any XML-style tag as a section boundary. The standard vocabulary is simply the most consistent choice for teams sharing prompts.

Worked example of the transformation

A plain-text prompt like:

You are a customer support agent. Answer the following question from a user based
on our return policy (returns are accepted within 30 days with receipt).
The user asks: {{question}}
Reply in a friendly tone, 2-3 sentences maximum.

Becomes:

<instructions>
You are a customer support agent. Answer the user question based on the return
policy provided in context. Reply in a friendly tone.
</instructions>
<context>
Return policy: returns are accepted within 30 days with receipt.
</context>
<user_input>
{{question}}
</user_input>
<output_format>
2-3 sentences maximum.
</output_format>

The structured version separates the policy (context) from the instructions, and makes the user input clearly distinct from both — which is also the correct separation for prompt injection safety.

Tips and notes

Separate your sections with blank lines or short headings before pasting; clearer input gives cleaner tagging. Keep <examples> tight — two or three high-quality input/output pairs usually beat a dozen mediocre ones. Put the <output_format> block last so it stays fresh in the model’s context when it starts generating. And if you also target GPT or Gemini heavily, compare the XML version against the Markdown formatter’s output and keep whichever the target model follows more reliably.