PDF Guides

How to Extract PDF Content as JSON (Text with Positions, Forms and Links)

Get structured data out of PDFs: text lines with coordinates, form values, annotations, bookmarks and metadata as JSON for scripts, data tools and AI.

Saizul Amin
Saizul Amin28 Oct 2026 · 3 min read
How to Extract PDF Content as JSON (Text with Positions, Forms and Links)

How to Extract PDF Content as JSON

Copying text out of a PDF gives you a jumble: columns mixed together, headers in the middle, no idea where anything sat on the page. Programs need structure. JSON, the standard data format of the web, can carry text along with its position, size and page, plus form values, links and bookmarks. This guide explains what you get and how to use it, with PDF to JSON.

What is in the JSON

The export contains:

  • document properties: title, author, creator, dates and PDF version;
  • pages: size, rotation and text;
  • text: as lines with x, y and size, as individual text runs with font and width, or as plain text per page;
  • annotations: comments, highlights and links with their rectangles, text, authors and URLs;
  • form fields: name, type and value of every field;
  • bookmarks: a nested tree with titles and target pages.

You choose which parts to include and how detailed the text should be.

Coordinates explained

PDF positions are measured in points, 72 to the inch. In the export, x is measured from the left edge and y from the top, as in most programs and web pages. The page width and height are included, so you can convert to percentages or millimetres. A total printed near the bottom right of an A4 invoice might be at x = 470, y = 710.

Lines or runs?

  • Lines join pieces of text that share a baseline. They are the most useful level for finding values: search for the line containing "Total due" and read the number.
  • Text runs are the pieces the PDF stores, often a word or a phrase in one font. They are useful for detecting bold headings, font changes and exact layout.

Typical uses

  • Invoice and statement parsing: find labels and read the values beside them using positions.
  • Collecting form answers: export the form section from many filled PDFs and combine them.
  • Feeding AI tools: structured text with positions helps a model understand tables and forms, and you can remove personal data before sending anything.
  • Quality checks: list every link and its target, or every comment and its author.

A small example script

In Python, after import json:

data = json.load(open("invoice.json"))
for line in data["pages"][0]["lines"]:
    if "Total" in line["text"]:
        print(line["text"])

Example

A two-page supplier invoice exported with lines gives 58 text lines. A short script finds "Total due 1,250.00" at y = 702, and the form section lists the four filled fields of the attached order form.

Choosing the text level

Start with lines; most tasks need nothing more. Switch to runs when you need to know which words are bold or in a different font, for example to detect section headings. Choose plain text when you only need searchable content, which gives the smallest file. Compact formatting removes spaces and line breaks, which can halve the size of large exports.

Many files

Load several PDFs and use Process all files to export each to its own JSON file in a ZIP. A script can then loop over the folder, which is how batches of invoices or forms are usually processed.

Comparing versions

Exporting two versions of a document to JSON and comparing the files in a diff tool shows exactly which text, links or form values changed between them.

Limits

Scanned pages contain no text unless OCR has been run. Tables are not recognised as tables; rebuild them from positions or use a PDF to Excel converter. The structure is this tool's own, documented by the example above.

Privacy

The PDF is read in your browser. Nothing is uploaded, which is important for invoices, contracts and forms with personal data.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages