Can ChatGPT extract data from PDFs?

Updated

In short

Yes. ChatGPT, Claude and similar assistants can read an uploaded PDF and return the values you ask for, and for a few varied documents that is the quickest method. For large numbers of similar documents it is a poor fit: the same file can give different answers, a missing value may be replaced by a plausible one, and you pay for every page.

Yes. ChatGPT, Claude, Gemini and similar assistants can read a PDF you upload and return the values you ask for, and for a handful of documents that is the fastest way there is. Whether it is the right way for hundreds or thousands of documents is a different question, and the answer depends on what happens when it is wrong.

What works well

  • One-off documents. A contract, a report, a policy you need three facts from. Upload it, ask, done.
  • Layouts nobody prepared for. A model does not need to have seen a supplier's invoice before to find its total.
  • Messy wording. "The amount payable", "balance due" and "please remit" all mean the total, and a model knows that.
  • Questions, not just fields. "Does this contract renew automatically?" has no label to search for.

What goes wrong

It can give a different answer next time. Ask the same question about the same file twice and the wording, and occasionally the value, can differ. A model update can change answers across a whole archive. For records you may have to stand behind later, that matters.

It fills gaps plausibly. If the value is not on the page, a model may still supply one that looks right: a tax number with the correct number of digits, a date in the right month. Nothing marks it as invented. A rule that finds nothing returns nothing; that difference is the heart of the matter.

Long documents and tables strain it. Values deep in a long file, columns of similar numbers, and tables that continue over pages are where mistakes concentrate: a figure taken from the wrong row, two digits swapped, a line skipped.

Scans depend on the picture. Assistants read scanned pages as images. Clear scans read well. Faint, skewed or low-resolution ones produce confident misreadings of exactly the digits you care about.

It costs per page, every time. Fine for ten documents. For ten thousand a month it is a real bill, and each one takes seconds, not milliseconds.

Your documents go to the provider. Check the terms for your plan: what is kept, for how long, and whether it is used for training. For personal or regulated data this can decide the question by itself.

Each provider also sets its own limits on file size and number of pages, and they change; check the current ones before you plan around them.

How to ask, if you do

A good prompt removes most of the avoidable errors.

Output
Extract these fields from the attached invoice and return only JSON:

- invoice_number (string)
- invoice_date (YYYY-MM-DD)
- total_due (number, no currency symbol or thousands separator)
- supplier_vat_number (string)

Rules:
- Copy values exactly as they appear. Do not correct or complete them.
- If a field is not in the document, return null for it. Never guess.
- For each field, also return the page number it came from.

Three things in it do the work: a fixed list of fields with types, permission to return null, and a request for where each value was found. Through an API, go further and require the JSON to follow a schema, so that a missing field cannot be silently dropped.

Check everything it returns

Treat the output as a draft.

  • Format. Does the date parse? Does the VAT number have the right shape?
  • Arithmetic. Do the lines add up to the subtotal, and subtotal plus tax to the total? The invoice guide shows the check in a few lines.
  • Presence. Search the document's text for each returned value. A value that appears nowhere in the file was invented. This one check catches most fabrications, and it needs only the text of the PDF, which any library gives you.
  • A person for whatever fails, and for a sample of what passes.

When to use something else

Models earn their cost on variety. They are a poor fit for the opposite case: the same kinds of document, in volume, where you need the same answer every time.

Your documentsUse
A few, each differentAn assistant, by hand
Many kinds, a few of eachA model through an API, with the checks above
A few kinds, hundreds or thousands of eachRules or templates: repeatable, fast, almost free per page
Anything audited, or with personal dataA method that is repeatable and keeps data where you need it

OCR, LLMs or templates compares the methods side by side.

AI once, instead of AI every time

There is a middle path, and it is how 100sands works. AI is used once, to set up a kind of document: you upload one to five samples, AI suggests the fields and each sample's values, you check and correct them, and AI sets up the extraction. The document type goes live only when it returns every value you checked on every sample. After that, documents are read by that fixed extraction with no AI involved.

What that changes:

  • The same file always gives the same answer.
  • Nothing is invented. Values are copied character for character from the file's text, and a value that is not in the document comes back empty (null), not guessed.
  • AI is used once, at setup. Each plan includes a number of AI setup runs a month; reading documents afterwards uses none, and each document counts as one, whatever its page count.
  • Your documents are not sent to an AI provider when you extract. Only the samples you upload for setup are.

What it does not do is what assistants are best at: it will not answer open questions, and it is not for documents whose layout you will see once. It also reads only PDFs and HTML files that contain text, not scans or photos. For a few kinds of document in volume, it gives you a model's ease of setup with a rule's reliability. The PDF data extraction API page has the details.

Questions

Can ChatGPT extract data from a PDF to Excel?

It can read a PDF and return the values as a table you can paste into a spreadsheet. Check the values against the document, especially numbers, and expect to repeat the work for each file.

Is ChatGPT accurate at extracting data from PDFs?

Often, on clear documents. Its typical mistakes are a value taken from the wrong row, swapped digits, and a plausible value supplied when the real one is missing. Always verify numbers.

What is the best prompt to extract data from a PDF?

List the fields with their types, ask for JSON only, say that values must be copied exactly, require null for anything not in the document, and ask for the page each value came from.

What should I use instead of an LLM for many similar documents?

Rules or templates built for that kind of document. They give the same answer every time, run in milliseconds and cost almost nothing per page.

Try it on your own documents

A free plan every month, no credit card. See the PDF data extraction API.

Start free