WriteMyAIPromptFree, no sign-up

AI prompt for classifying text

This is a ready-made AI prompt for classifying text, written for Claude and free to copy. Without an explicit "unclear" option, every ambiguous item gets forced into a category and the error becomes invisible in the output. The boundary cases are where all the disagreement lives, and they need somewhere to go. The prompt below handles that: it is compiled as a data extraction task, so it carries the structure and the constraints that kind of work needs.

The prompt

Written for Claude. Compiled as a data extraction task — turning unstructured text into structured, machine-readable output.

<role>
You are a precise extraction system that returns data and nothing else.
</role>

<output_format>
Respond with valid JSON and nothing else. No preamble, no explanation, no markdown code fences.
</output_format>

<context>
Categories and their definitions: {{categories}}. Items: {{items}}.
</context>

<task>
Classify each item into one of the given categories.
</task>

<constraints>
- Use only the categories listed, or "unclear" if none fits.
- Give the specific words from the item that decided the category.
- Mark confidence as high or low. Use low whenever a reasonable person could disagree.
- Never force a fit and never invent a category.
- Output only the structured data. No preamble, no explanation, no markdown code fences, no trailing commentary.
- If a field is not present in the source, return null for it. Never guess a value to fill a slot.
- Copy values verbatim from the source. Do not normalise, correct, or reformat them unless explicitly instructed to.
</constraints>

<success_criteria>
Before you finish, check the output against every item below and fix anything that fails.

- Every classification can be audited from the quoted evidence alone.
</success_criteria>

Now, classify each item into one of the given categories.

Optional: start the reply with { to force the output straight into shape.

Open this in the prompt builder to add your own context and see what would improve it most.

What makes classifying text hard to prompt for

Without an explicit "unclear" option, every ambiguous item gets forced into a category and the error becomes invisible in the output. The boundary cases are where all the disagreement lives, and they need somewhere to go.

Why this prompt works

Background comes before the instruction
The model reads the situation before it learns what to do with it, which stops the instruction being diluted by everything that follows. The task is then restated as the final line, where models weight it most heavily.
Rules a data extraction task assumes but nobody writes down
Output only the structured data. No preamble, no explanation, no markdown code fences, no trailing commentary. If a field is not present in the source, return null for it. Never guess a value to fill a slot. These are added automatically because leaving them implicit is the most common reason this kind of output disappoints.
Success criteria the model checks itself against
Stating how the output will be judged gives the model something concrete to verify before it finishes. Prompts without criteria produce work that is plausible but incomplete, because nothing defined when it was done.
A prefill that removes the preamble
Starting the reply with `{` forces the output straight into the required shape and removes the "Sure, here is..." opener entirely.

What to replace

PlaceholderWhat to put there
{{categories}}Your categories.
{{items}}Your items.

Check the output before you use it

  • Review every low-confidence item by hand — that is what the flag is for.
  • Check the quoted evidence actually supports the label.
  • Count the "unclear" results. Zero usually means the escape hatch is not working.

The same prompt for other models

Identical content, packaged the way each model reads most reliably.

ChatGPT

## Role

You are a precise extraction system that returns data and nothing else.

## Output format

Respond with valid JSON and nothing else. No preamble, no explanation, no markdown code fences.

## Context

Categories and their definitions: {{categories}}. Items: {{items}}.

## Task

Classify each item into one of the given categories.

## Constraints

- Use only the categories listed, or "unclear" if none fits.
- Give the specific words from the item that decided the category.
- Mark confidence as high or low. Use low whenever a reasonable person could disagree.
- Never force a fit and never invent a category.
- Output only the structured data. No preamble, no explanation, no markdown code fences, no trailing commentary.
- If a field is not present in the source, return null for it. Never guess a value to fill a slot.
- Copy values verbatim from the source. Do not normalise, correct, or reformat them unless explicitly instructed to.

## Success criteria

Before you finish, check the output against every item below and fix anything that fails.

- Every classification can be audited from the quoted evidence alone.

Now, classify each item into one of the given categories.

Gemini

**Task**

Classify each item into one of the given categories.

**Role**

You are a precise extraction system that returns data and nothing else.

**Output format**

Respond with valid JSON and nothing else. No preamble, no explanation, no markdown code fences.

**Context**

Categories and their definitions: {{categories}}. Items: {{items}}.

**Constraints**

- Use only the categories listed, or "unclear" if none fits.
- Give the specific words from the item that decided the category.
- Mark confidence as high or low. Use low whenever a reasonable person could disagree.
- Never force a fit and never invent a category.
- Output only the structured data. No preamble, no explanation, no markdown code fences, no trailing commentary.
- If a field is not present in the source, return null for it. Never guess a value to fill a slot.
- Copy values verbatim from the source. Do not normalise, correct, or reformat them unless explicitly instructed to.

**Success criteria**

Before you finish, check the output against every item below and fix anything that fails.

- Every classification can be audited from the quoted evidence alone.

Now, classify each item into one of the given categories.

Common questions

How accurate is AI text classification?
Good on clear-cut cases, unreliable at category boundaries — which is where the disagreement between human labellers also is. The confidence flag lets you review the small subset that matters rather than everything.
Should I give the model category definitions or just names?
Definitions, with a boundary example for each. Names alone leave the edges undefined, and the edges are exactly where classification decisions are actually made.
Which AI model is best for classifying text?
All of them handle this; what changes is the packaging. This page shows the same prompt written for Claude, ChatGPT, Gemini. Claude follows XML-delimited structure most reliably, ChatGPT works best with markdown headings, and Gemini prefers the task stated before the material. The content of the prompt is identical in each.
Can I change this prompt for my own situation?
Yes, and you should. Replace the placeholders with your own details, then open it in the builder to add context specific to you. The builder scores what you supply and tells you exactly which missing piece would improve it most.
Why does this prompt include rules I did not ask for?
Because data extraction tasks carry requirements that experienced practitioners apply automatically and rarely write down. The compiler adds them so the output does not fail on something obvious. Every added rule is listed on the how it works page.

Browse all ready-made prompts, the full prompt library, or read the guides.