Convert PDF text to JSON — each line with its position and font size

Drop a text-based PDF and press Convert to JSON to get every line of text as structured data, grouped by page, with optional coordinates and font size.

Live demo · real result from this tool

Drop your PDF here

or paste with Ctrl+V · nothing is uploaded · add several to process them in one go

For example 1-3, 5, 8- (8 to the end), odd, even or all.

Your result appears here — processed on your device.

Processed on your device — nothing is uploaded.

How to use PDF to JSON

  1. Drop a PDF onto the box or press Choose a file.
  2. In Pages, leave all or type pages such as 1 or 2-4.
  3. Keep Include position and font size ticked for coordinates, or untick it for text only.
  4. Press Convert to JSON, then copy the result or download it as a .json file named after your PDF.

What it does and when to use it

JSON is the easiest format to feed into a script, a spreadsheet import, a database or a no-code automation. This tool is meant for people who want to process PDF text with their own rules: pulling the invoice number that always sits at the top right, finding the total on the last line of a receipt, checking that every page of a report has a footer, or detecting headings by font size. The coordinates let you filter by region, for example “lines with y under 100 on page 1”.

For reading or copying text, the PDF text extractor is simpler. For a document with headings and lists, PDF to Markdown keeps the structure in a human-friendly way.

How it works

pdf.js (pdfjs-dist) reads each chosen page’s text layer in your browser. Every piece of text comes with a transform that gives its position and size. The tool converts those to page coordinates with the origin at the top left, groups pieces into lines, sorts lines from top to bottom, and rounds the numbers to one decimal place. The output has this shape:

Key Meaning
page Page number
width, height Page size in points (A4 is 595.28 × 841.89)
lines[].text The line’s text
lines[].x, y Left edge and baseline, from the top-left corner
lines[].width Horizontal extent of the line
lines[].fontSize Largest font size on the line, in points
lines[].bold Whether every piece on the line uses a bold font (from the font’s real name or bold flag)

Nothing is uploaded. If the PDF uses standard fonts or character maps it does not contain, pdf.js may download that data from cdn.jsdelivr.net.

Worked examples

Page 1 of an invoice, with coordinates. The output begins:

{
  "pages": [
    {
      "page": 1,
      "width": 595.28,
      "height": 841.89,
      "lines": [
        { "text": "Invoice 2041", "x": 72, "y": 61.9, "width": 119, "fontSize": 20, "bold": true },
        { "text": "Billing summary", "x": 72, "y": 97.9, "width": 108.9, "fontSize": 14, "bold": true },

The real output puts each key on its own line. The title and the section heading are set in Helvetica Bold, so bold is true for both, even though pdf.js lists the font under a coded name.

Text only. With the option unticked, each line is just { "text": "Invoice 2041" }, which is handy when you only need reading order.

Limits and tips

  • Scanned PDFs have no text layer; run OCR PDF first.
  • Rotated text, text along a curve and text inside images are not handled specially.
  • Large documents give large JSON files; convert a page range when you only need part of it.

Frequently asked questions

Which way do the coordinates run?
In points (1/72 inch) from the top-left corner of the page as displayed. x is the left edge of the line, y is the distance from the top of the page down to the line's baseline, and width is how far the line runs to the right.
How is bold detected?
pdf.js gives each piece of text a coded font name, so with positions included the tool also loads the page's fonts and reads each font's real name and bold flag, such as Helvetica-Bold. A font that is bold only in its drawing, with no bold name or flag, still reads as false, so fontSize remains the surer way to spot headings.
What is a line here?
All pieces of text that share a baseline (within half the font size) are joined left to right into one line. Two columns side by side therefore end up in the same line.
Can I get each word or character with its own position?
No. The smallest unit is a line. For a table laid out in columns, try the PDF table extractor, which splits lines at wide gaps.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close