Back to Prompting

How Do You Use Delimiters and Sections in a Prompt?

How Do You Use Delimiters and Sections in a Prompt?
AI Tutorials Team 3 April 2026

When a prompt contains instructions, a document, some examples and a question, the model has to work out where each begins. Left unmarked it infers from context, which works most of the time and fails in the specific case where a document contains something that reads like an instruction.

What goes wrong without boundaries?

  • Content read as instruction. A line in a document telling the reader to do something.
  • Instruction read as content. Your request summarised rather than followed.
  • Merged sections. Two documents treated as one, with values migrating between them.
  • Examples answered. The final example treated as the real request.

What markers work?

Anything visually distinct and consistently applied. Tag-style markers work particularly well, since the pattern is common in training data and the closing marker is unambiguous:

<instructions>
Extract every deadline with its clause number.
</instructions>
<document>
[the contract]
</document>

Lines of dashes, capitalised headings and triple backticks all work too. What matters is that the same marker is not used for two different purposes.

Does the choice of marker matter?

Less than consistency. Some providers recommend a particular style in their documentation and it is worth following for their models, since it will have appeared frequently in training.

The one thing to avoid is a marker that could plausibly appear inside your content, which is why arbitrary strings sometimes beat obvious ones for untrusted input.

How does this relate to injection?

It helps and does not solve it. Marking a section as untrusted content, and instructing the model to treat anything inside it as data rather than as instruction, measurably reduces the rate at which planted instructions are followed.

It is a mitigation rather than a boundary, since the model can still be persuaded. Anything consequential needs controls outside the prompt.

Do they cost anything?

A handful of tokens, which is irrelevant against the failures they prevent. The only real cost is discipline: markers have to be applied consistently, and a prompt where three of four sections are labelled is worse than one where none are, because the unlabelled part looks like it belongs to whatever preceded it.

Where should each section go?

Instructions first, content in the middle, and the specific request last. Attention is most reliable at the beginning and end, so the request that generation immediately follows should sit closest to it.

For long documents, restating the instruction after the content is worth the few tokens it costs.

What about the user's own text?

Worth marking too, in any system where a person's message is combined with instructions of yours. Without a boundary, a user who writes something that reads like a directive can shift behaviour without intending to, and a user who does intend to has an easier time of it.

How do you handle several documents?

Label each one and require the label in the output. Without that, values migrate between sources and there is no way to tell which came from where, which is the most common silent failure in multi-document work.

Does this matter in a chat window?

Less, because attachments and messages are already separated by the interface. It becomes relevant when you paste several things into one message, which is exactly when people forget.

A line saying what each pasted block is takes five seconds and prevents the model guessing.

Should the output be marked up too?

Where anything downstream reads it, yes. Asking for the answer inside a named tag makes extraction trivial and removes the problem of a model adding a sentence before or after the part you wanted.

It is also useful when a response has several parts. A draft in one section and the notes about it in another can be separated cleanly, where a single block of prose containing both has to be split by guesswork.

What is the underlying principle?

The model receives one undifferentiated stream of text, and every distinction you can see on screen has to be encoded in that stream. Whitespace and formatting carry less meaning than they appear to, so anything structural has to be stated explicitly rather than implied by layout.