PromptKitHub guide

Using AI to Extract Structured Data From Messy Text

Data extraction is one of the clearest uses for structured AI prompts. The key is to define the fields, show what missing information should look like and keep the original text available for checking.

Quick takeaway: Use it for extracting names, dates, issue types, requirements, product attributes or other fields from semi-structured text.

1. Define the schema

List the exact fields you want and what each field means.

2. Specify missing-value behavior

Tell the assistant to use “Not found” or another fixed value instead of guessing.

3. Preserve source wording where needed

For important fields, ask for a short source excerpt so a reviewer can trace the extraction.

4. Use a stable format

JSON, a table or fixed labels can make repeated extraction easier to inspect.

5. Sample-check results

Compare a selection of outputs against the original documents before relying on the process at scale.

Example: extract support case fields

Fields might include issue type, product, customer goal, deadline and requested action. If the email does not contain a deadline, the result should say “Not found,” not invent one.

Example prompt
Extract the following fields from the text: issue type, product, requested action, deadline, and urgency.
Rules: use only information stated in the source; write “Not found” when a field is absent; do not infer urgency from tone.
Return a table with field, value, and supporting quote.

SOURCE:
[paste text]

Common mistakes

FAQ

Can AI extraction replace a database parser?

It depends on the data and required reliability. AI can help with messy language, while deterministic parsing may be better for stable formats.

Why include a supporting quote?

It gives reviewers a quick way to trace an extracted value back to the source.

Practical next step: Try the workflow with one real task. Keep the source material visible, save the prompt that works and note what you still had to correct by hand.
PRACTICAL FIELD NOTE

Worked scenario: Extracting invoice fields from supplier notes

This is an illustrative example, not a report of a live product test. Replace the sample details with source material you can verify.

INPUT / CONTEXT

Source note: “Northstar Supplies — invoice NS-1048 — total SGD 428.60. Please arrange payment next week.” No exact due date is stated.

TRY THIS IN YOUR AI ASSISTANT

Return JSON with supplier, invoice_number, currency, total, due_date and evidence. Use null for missing values. Do not convert “next week” into an exact date unless the source date and rule are supplied.

REVIEW BEFORE USE

Check each value against the source. The due date should remain unknown or preserve the phrase as source text; do not guess a calendar date.

Protect the source data

Extraction workflows should preserve uncertainty. If a field is not present in the source, a reliable process should mark it as missing rather than creating a plausible but unsupported value.

PUT IT INTO PRACTICE

Extracting invoice fields from supplier notes

Use this as a starting instruction with your preferred AI assistant. Replace bracketed placeholders with your own source material; this is an illustrative template, not a report of a real-world test.

Review before using the result

Validate the JSON syntax, compare every extracted value with the source and ensure missing values are null rather than guessed.