Delimiter Prompting: How to Use Separators to Get Cleaner, More Reliable AI Outputs

Close-up of a backlit computer keyboard representing prompt writing

Delimiter prompting means wrapping the different parts of a prompt—instructions, reference text, examples, user input—in clear separators such as triple quotes, XML tags, or markdown fences, so the model can tell exactly where one section ends and the next begins. It is one of the simplest prompting techniques to adopt, and it consistently reduces the chance that a model mixes up your instructions with the content you handed it.

What Are Delimiters in a Prompt?

A delimiter is any consistent marker you place around a block of text to separate it from the rest of the prompt. Common choices include triple quotes (“””), triple backticks, XML-style tags like <document></document>, or markdown headers. OpenAI’s own prompt engineering guidance recommends using delimiters such as triple quotation marks, XML tags, or section titles to clearly indicate distinct parts of the input, and Anthropic goes a step further: its documentation on using XML tags to structure prompts notes that Claude was trained with particular attention to XML tags, so wrapping instructions, context, and examples in tags like <instructions> or <context> tends to produce more consistent results.

Why Do Delimiters Make AI Outputs More Reliable?

Without delimiters, a model has to guess where your instructions stop and the content you want processed starts. That guesswork gets worse as prompts grow longer or include pasted text from emails, tickets, or documents. Delimiters remove the ambiguity: the model can point to exactly the span of text it should summarize, translate, or analyze, rather than treating the whole prompt as one undifferentiated block. This matters most in three situations: when you paste in long or messy source text, when you give the model multiple examples to learn a pattern from, and when your instructions and the content you’re asking it to act on could otherwise be confused with each other.

Which Delimiter Styles Actually Work Best?

There is no single “correct” delimiter, but a few styles cover almost every use case:

  • Triple quotes or backticks — quick and readable for wrapping a single block of pasted text, such as an email or a paragraph to rewrite.
  • XML-style tags — the most reliable option for Claude specifically, and useful anywhere you need to label multiple distinct sections, such as <instructions>, <context>, and <examples>.
  • Markdown headers — readable for humans reviewing the prompt later and works well when the prompt itself is long and structured like a document.
  • Numbered or lettered sections — helpful when you need the model to reference “the second document” or “example 3” later in its response.

The technique pairs naturally with meta-prompting, since a model asked to critique or rewrite a prompt will also produce cleaner suggestions when the original prompt’s sections are clearly delimited.

How Do You Combine Delimiters With a Structured Output Request?

Delimiters work in both directions. You can use them to mark the input you’re feeding the model, and you can ask the model to use the same style of tags to structure its response—for example, requesting a <summary> tag and a separate <risks> tag in the output. This makes the response easier to parse programmatically if you’re feeding it into another system, and it’s a technique worth versioning and testing over time rather than treating as a one-off tweak. Teams that iterate on prompts seriously usually end up tracking these changes the same way they track code, which is the idea behind prompt versioning.

Frequently Asked Questions

Do delimiters work the same way across ChatGPT, Claude, and Gemini?

The general principle holds across providers: clearly separating instructions from content improves reliability everywhere. The specific recommendation differs slightly—OpenAI’s guidance highlights triple quotes and section titles, while Anthropic specifically recommends XML tags for Claude because of how its training data was structured. When in doubt, XML tags are a safe default since every major model can parse them correctly.

Can delimiters alone stop prompt injection?

No. Delimiters make it harder for injected instructions hidden in pasted content to be mistaken for your own instructions, but they are not a complete defense on their own. If you’re building an application that processes untrusted text, pair delimiters with the broader defenses covered in this guide to prompt injection, such as input validation and least-privilege tool access.

What is the simplest delimiter to start with?

Triple quotes around any pasted text is the lowest-effort starting point and works in almost every chat interface. If you’re writing prompts programmatically or working specifically with Claude, switch to XML tags once your prompts have more than one distinct section, since tags scale better than quotes when you need to label several parts of the same prompt.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top