Extract Data From Text with AI
Free text in, named fields out. The extraction prompt pattern that turns any unstructured text into consistent, parseable records.
The six sections a reliable extraction prompt needs: source guidance, field definitions, extraction rules, missing-data behavior, ambiguity policy, example.
Most extraction prompts are one sentence and a hope. The ones that survive production have an anatomy: a SOURCE section that tells the model how to read this kind of text, FIELDS that define each piece of information, per-field EXTRACTION RULES (emails validated, dates ISO-formatted, identifiers untouched), a MISSING DATA contract, an AMBIGUITY POLICY, and an example of a valid extraction. This resource loads a job-posting extraction that exercises every section — including a salary_range field whose rule explicitly stops the model from collapsing a range into one number.
Check each section's job
SOURCE teaches reading, FIELDS define meaning, RULES handle the traps, MISSING DATA and AMBIGUITY remove improvisation, the EXAMPLE shows the shape.
Watch the salary_range rule
"Extract the range as written — do not collapse it to one number." Per-field rules exist for exactly these traps.
Swap in your own fields
Replace the job-posting fields with yours; the engine derives new rules from the names you choose.
A per-field EXTRACTION RULE handles that trap directly: salary_range must be extracted as written (e.g. "60,000–75,000 EUR") and explicitly not collapsed to a single number. Other fields get their own rules too; application_deadline uses ISO YYYY-MM-DD when the date can be determined. The extraction-prompt-generator derives these from your field names; you run the prompt in your assistant and check the JSON before trusting it.
It includes the field with an empty string "" and never invents or guesses a value, per the MISSING DATA contract, backed by an AMBIGUITY POLICY that extracts only what's explicitly stated and treats implied-but-unstated values as missing. Output is a single JSON object using the exact field names, no markdown fences. The generator writes this; you still verify blanks are genuinely absent, not just missed.
Free text in, named fields out. The extraction prompt pattern that turns any unstructured text into consistent, parseable records.
Invoice number, vendor, dates, total, currency — extracted into clean fields with strict no-inference rules, ready for accounts payable.
The most consequential setting in any extraction prompt: what the model does when the field isn't in the text. Four behaviors, and when each is right.
Stop getting 'Sure, here is the JSON…' — the output-contract pattern that forces models to return only parseable JSON: schema, example, and a strict rule block.
Billing, Technical, Account, How-To, Feature Request — ticket triage with definitions that decide the borderline cases for the model.
The JSON won't parse and you can't see why. Deterministic cause-sniffing — trailing commas, single quotes, unclosed brackets — and the repair prompt that fixes it.
Build prompts that extract defined fields from unstructured text — emails, invoices, tickets, résumés.
Build a text classification step you can automate on — pull out the unit to classify, assign a label from a fixed set, and validate the label is one you actually allow.
AI extraction returns clean JSON that quietly means something different each run. Design the extraction schema first — each field's meaning, type, allowed values, missing-value rule, and required evidence — and review it before a single record is pulled.