By · Updated

Prompt Formatter

Structured Prompts With XML Tags, Markdown Headings or Plain Labels for Any LLM

No ratings yet

OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.

How the Prompt Formatter works

This prompt formatter builds a structured prompt from its parts. Fill in a role, a task, constraints and an output format, paste the background into the main box as context, and get one prompt wrapped in XML tags, Markdown headings or plain labels, ready to paste into Claude, ChatGPT or Gemini.

How the prompt formatter works

Large language models follow a prompt more reliably when its parts are clearly separated, so instructions are not mistaken for the document they apply to. The formatter takes five parts in a fixed order, role, task, context, constraints and output format, and wraps each one in the style you choose. Empty parts are skipped, so a prompt with only a task and context gives just those two sections.

The formula for each section is opening marker, content, closing marker: <task> and </task> for XML tags, a "## Task" heading for Markdown, or "TASK:" for plain labels. Context comes from the main text box because it is usually the longest part.

First example. Role "You are a careful copy editor", task "Shorten this email to 100 words" and an email pasted as context give three tagged blocks: role, task and context.

Second example. The same parts with Markdown headings give "## Role", "## Task" and "## Context", each followed by its text.

How many sections should a prompt have? As many as you have content for; most need a task and context, and add constraints and a format when the answer must fit a shape.

Common section tags in structured prompts and what goes in each

Tag Holds Example content
<role> Who the model should act as You are a careful copy editor.
<task> The single job to do Shorten the email below to 100 words.
<context> Background the model needs The reader is a new customer.
<instructions> Step-by-step directions 1. Read the draft. 2. Cut filler.
<constraints> Hard rules and limits Keep all prices and dates.
<output_format> The exact shape of the answer Return JSON with keys subject and body.
<audience> Who will read the result Finance managers in the UK.
<tone> Voice and register Friendly but brief.
<document> One source text The pasted contract.
<documents> Several sources, each tagged …
<example> One sample input and output Input: hi. Output: Hello.
<examples> Several samples Three short before-and-after pairs.
<data> Structured input A CSV export.
<schema> A format the answer must match A JSON Schema.
<query> The user's question What is the notice period?
<rules> A numbered rule list Never invent figures.
<style_guide> House style Use British spelling.
<thinking> Space to reason before answering Work through it here first.
<answer> Where the final answer goes Only the final reply.
<quotes> Exact extracts to ground an answer Quote before you answer.
<sources> Citations to use Cite by document index.
<feedback> Notes on a previous attempt Too long; drop the second paragraph.

Tips and pitfalls

Anthropic recommends XML tags for Claude, and they work well with other models too. Keep tag names consistent and refer to them in the task, such as "using the email in the context tags". Put long documents before the task. Check the result in a token counter if you are near a context limit.

FAQ

Why use XML tags in a prompt?

Tags mark exactly where each part starts and ends, so the model can tell your instructions from a pasted document that may itself contain instructions. They also let you refer to parts by name and pull tagged sections out of the reply.

XML tags or Markdown headings?

Both work. XML tags have explicit closing markers, which helps when content contains its own headings, and Anthropic's guides use them for Claude. Markdown headings read more naturally and suit chat interfaces where people also read the prompt.

Do the tag names matter?

No model needs particular names; what matters is that they describe the content and stay consistent. The formatter uses role, task, context, constraints and output_format, and you can rename them after copying if your team uses others.

Where do examples go?

Add them to the context or constraints field, or paste the result and add an examples section by hand. Two or three short input and output pairs showing the exact format you want usually help more than a longer description.

Does formatting change the cost?

Slightly. Tags and headings add a few tokens per section, typically under 30 for a whole prompt, which is negligible next to the content. The structure usually saves more by reducing retries from misread instructions.

See also: all AI tools, Dev Utilities, Formatters & Validators, Data & Encoding, Security & Identifiers, SEO, Accessibility.

Related tools