Back to library
AI
best practice

Automate Data Extraction from Messy Documents Using Structured Output

Convert messy, unstructured text into organized tables in seconds.

Apply a JSON schema to unstructured text inputs to automatically map key information into a clean, machine-readable format for reports or databases.

Google Gemini

The Scenario

You have a transcript from a meeting or a long messy document and need to extract specific action items and dates without reading the whole thing.

Before & after

The old way

You would manually scan long reports to find specific metrics and type them into a table, which could take 20–30 minutes for a long document.

With AI

By specifying a JSON schema, you ensure the AI focuses only on the requested fields. This reduces token noise and provides the results in seconds.

The Prompt

Extract the key entities from the following text: [PASTE_UNSTRUCTURED_DOCUMENT]. 
Return the output in JSON following this schema:
{"type": "object", "properties": {"date": {"type": "string"}, "action_items": {"type": "array", "items": {"type": "string"}}, "attendees": {"type": "array", "items": {"type": "string"}}}}

Controlled generation is particularly useful for information extraction. By defining the keys you want in your schema (e.g., 'date', 'amount', 'vendor'), Gemini ignores the conversational filler and maps the unstructured text directly to your structured keys.

Source

Release notes  |  Gemini API  |  Google AI for Developers
"Mastering Controlled Generation with Gemini 1.5: Schema Adherence for Developers"