Tips & Tricks

How to Export OCR Results From a PDF to JSON

Running OCR PDF on a scanned document produces recognized text, but most OCR tools output that text as a flat text file or embed it back into the PDF. Exporting OCR results directly to JSON gives you structured, machine-readable data that can be fed into databases, search indexes, content management systems, and automated workflows. A 2025 survey by AIIM International found that 43 percent of organizations now prefer structured data formats like JSON for document-derived text because they integrate more easily with modern cloud applications and AI pipelines (AIIM, "State of Intelligent Information Management", 2025).

Key Takeaways

Exporting OCR results to JSON preserves the structure of the recognized text, including page numbers, word coordinates, and confidence scores, that is lost when exporting to plain text. Most modern OCR engines support JSON output natively, but the feature may need to be enabled in settings or selected from an export format menu. The resulting JSON file can be used for full-text search, data extraction pipelines, and training machine learning models on document content.

For developers integrating OCR JSON into applications, most JSON output formats include a version field that identifies the schema version. Always check this field before parsing to avoid breaking changes when the OCR engine updates its output format. A simple version guard at the start of your parsing code prevents cryptic errors when the JSON structure changes between engine versions.

How to Export OCR Results From a PDF to JSON

Why JSON Output Is Better Than Plain Text for OCR Results

Plain text output from OCR discards everything except the characters themselves. You get the words but lose the page number where each word appeared, the bounding box coordinates that tell you where on the page the text sits, the confidence score that indicates how certain the OCR engine is about each character, and any structural information like paragraph breaks and column layouts. JSON preserves all of this. A JSON Scanned PDF OCR output file typically contains an array of page objects, each with an array of text block objects, each containing the recognized text plus its position, size, and confidence metadata.

This structure enables downstream automation that is impossible with plain text. A script can read the JSON file and extract only text from a specific region of each page, such as the header area or a sidebar column. It can filter out low-confidence OCR results to avoid polluting a search index with garbled text. It can reconstruct the reading order of a multi-column layout by sorting text blocks by their Y and X coordinates. None of these operations are possible with a flat text file from OCR.

WukongPDF

Try PDF OCR

No installation needed. Works directly in your browser.

Get Started โ†’

Step-by-Step: Export OCR Results to JSON

Before running OCR, check the scanned PDF's image resolution. Most OCR engines perform best when the input page images are at 300 DPI. Below 200 DPI, recognition accuracy drops noticeably. Above 400 DPI, the processing time increases without a meaningful improvement in accuracy. If your scanned PDF has low-resolution page images, consider upscaling them to 300 DPI before running OCR with JSON output. The extra preprocessing step noticeably improves the quality of the JSON data.

Open your scanned PDF in an OCR tool that supports structured output. Tesseract, the most widely used open-source OCR engine, supports JSON output through its command-line interface and through most applications that bundle it. In Tesseract, adding the output format flag produces a JSON file alongside the recognized text. Commercial OCR APIs from Google Cloud Vision, Amazon Textract, and Microsoft Azure Form Recognizer all return JSON by default, with the recognized text organized by page, block, paragraph, line, and word.

After running OCR with JSON output enabled, open the resulting file in a text editor to understand its structure. The JSON will contain arrays of page objects. Each page object contains the page dimensions and arrays of block objects. Each block contains the recognized text, a confidence score typically between 0 and 100, and bounding box coordinates that describe the block's position on the page. Familiarity with this structure lets you write simple scripts to extract exactly the data you need. WukongPDF's OCR tool includes a JSON export option that organizes recognized text with page numbers, confidence scores, and positional data, so you do not need to configure a separate OCR engine to get structured output.

Common JSON Structures for OCR Output

Most JSON Scanned PDF OCR outputs also include a global metadata section at the top of the file that records the OCR engine name, version, processing date, and the language or languages detected in the document. This metadata is valuable for audit trails and for debugging OCR quality issues. If you are processing documents from multiple sources, the metadata tells you which engine produced each result and whether the engine version has changed between batches, which can explain differences in recognition quality.

FieldDescriptionExample Value
pagePage number in the original document3
textRecognized text content"Invoice #4521"
confidenceOCR confidence 0 to 10094.7
bboxBounding box [x, y, width, height] in pixels[120, 340, 400, 28]
block_typeType of content block"paragraph" or "table" or "line"
languageDetected language of the text"en"

Using OCR JSON Data in Automated Workflows

Error handling is worth planning for upfront. An OCR run on a page with very poor image quality may produce a confidence score below 50 percent for most recognized words. Your workflow should define a minimum confidence threshold below which results are flagged for human review rather than automatically ingested into a database or search index. Sending low-confidence Scanned PDF OCR output straight into a production system pollutes the data with errors that are far more expensive to clean up later than to flag for review at the point of extraction.

Once the OCR results are in JSON, the automation possibilities expand significantly. A common pattern is to write a script that watches a folder for new scanned PDFs, runs OCR with JSON output, parses the JSON to extract specific fields such as invoice numbers or dates from known positions on the page, and inserts those values into a database or spreadsheet. Because the JSON includes positional coordinates, the extraction script can target text in specific regions of the page regardless of the document's overall content.

For search applications, the JSON output can be fed into a search index like Elasticsearch or Algolia. Each page becomes a searchable document with the page number as a metadata field. The confidence scores let you tune the search relevance by giving higher weight to high-confidence OCR text. Users searching for a term see results ranked by the OCR engine's certainty that the term actually appears on the page, reducing false matches from misrecognized characters.

For AI and machine learning pipelines, structured Scanned PDF OCR output in JSON is the standard input format. Large language models and document understanding systems consume JSON representations of

Frequently Asked Questions

How should I store OCR JSON files alongside the original PDFs for long-term access? Store the JSON files in the same folder as the PDFs with matching filenames. For example, report-2025.pdf and report-2025.ocr.json. This naming convention makes it trivial for scripts to find the Scanned PDF OCR output for a given PDF. For large archives, consider storing the JSON in a document database that supports full-text search rather than as flat files.

Does JSON output from OCR increase file size compared to plain text?

Yes, usually by a factor of 3 to 5 times. A 10-page scanned document that produces 15 KB of plain text might produce a 50 to 75 KB JSON file. The additional size comes from the structural metadata: page numbers, bounding boxes, and confidence scores for every recognized word. For most applications, this size increase is negligible. Only at very large scale, such as millions of pages, does it become a storage consideration worth planning for.

Can I convert existing plain text Scanned PDF OCR output to JSON?

Not meaningfully. Once OCR results have been flattened to plain text, the positional data and confidence scores are lost and cannot be reconstructed from the text alone. If you need structured OCR data from previously processed documents, the most reliable approach is to re-run OCR on the original scanned PDFs with JSON output enabled.

Which OCR engines produce the most useful JSON output?

Cloud-based OCR services from Google, Amazon, and Microsoft generally produce the most detailed JSON output, with word-level bounding boxes and confidence scores. Tesseract produces solid JSON at the line and word level. The best choice depends on your volume, budget, and whether privacy requirements allow sending documents to a cloud service.

Can I convert OCR JSON output back into a searchable PDF? Yes, though the process requires a PDF generation library that can place text objects at specific coordinates. The bounding box data in the JSON output tells you exactly where each word belongs on the page. This is the reverse of the extraction process and is useful when you need to create a searchable PDF from corrected OCR text after fixing recognition errors in the JSON data.

WukongPDF

Try PDF OCR

No installation needed. Works directly in your browser.

Get Started โ†’