How to Convert PDFs to JSON Using AI

A step-by-step guide to using AI to convert PDFs to structured JSON in automated workflows.

A webhook export in Cradl AI with the JSON payload for a processed document

Converting PDFs to JSON is a common challenge when working with documents like invoices, bills of lading, receipts, contracts, or forms. PDFs aren’t built for structured data exchange, and manual extraction into JSON is slow, brittle, and hard to maintain at scale. AI makes it possible to extract structured data from PDFs and convert documents into clean, machine-readable JSON with far fewer errors.

In this post, we show how to set up an AI agent that automatically extracts data from PDFs and outputs validated JSON in minutes, using large language models with human-in-the-loop review.

For a broader implementation view, start with The 2026 Guide to Document Data Extraction Using AI. If you are evaluating whether LLMs should handle OCR directly, see Using LLMs for OCR and PDF Parsing.

For a production-ready overview, see Cradl AI PDF-to-JSON automation.

Before we get started

You’ll need:

Running your first PDF extraction

Create a new agent and describe the document type it should handle, or start from one of the popular use cases such as Invoices, Receipts, or Bills of lading. Click Create agent to get an agent with a suggested set of fields.

Then open the Runs tab, click Upload, and add a PDF. When the run has finished, select it to review the extracted data next to the original document.

Reviewing data extracted from a PDF in Cradl AI, with the source document on the left and the extracted fields on the right
Extracted fields next to the source document.

Defining the fields in your JSON

The fields on your agent become the keys in your JSON, so this is where you design the output. Open the Builder tab and select the Document AI node. From there, you can add, remove, or refine fields based on your needs.

Editing a table field in the Cradl AI builder, with a field name, a prompt and a list of typed columns
Editing a table field and its columns.

Take a moment to pick the right type for each field. With number and date types for amounts and dates, you spend less time cleaning up formats like 1 234,50 or 17.05.2025 in your own code. Repeated data, such as line items, containers, or transactions, belongs in one table field with a column per value. And where the document is ambiguous, use the prompt to say what you mean, for example whether “date” is the issue date or the due date.

When you’re satisfied, go back to Runs and upload a new document to see how your agent performs.

Configuring human-in-the-loop validation

By default, your agent is created with human-in-the-loop validation. If the AI is uncertain whether it has extracted the right information, the document is routed to a reviewer before it is exported. Select the Human review node in the builder to choose who reviews flagged documents.

What gets flagged is decided by the Guardrails on each field. To change them, open a field in the Document AI node and add or edit its guardrails, for example the confidence a value needs before it is accepted without review. If you want all values to be sent directly to your endpoint without a review step, remove the guardrails from your fields.

Exporting the data to JSON

There are two ways to get JSON out of an agent. You can download the extracted data for a run manually, or you can set up an automatic export so every processed document is sent to your system. For the automatic route, you’ll need an HTTP endpoint.

Most automation platforms can provide one through a webhook or HTTP request trigger. Cradl AI also has native integrations for Power Automate, n8n, and webhooks, so if you’re planning to integrate with them, I recommend using the native integrations instead.

In the Builder tab, click Add export and choose Webhook. Choose the HTTP method and enter the URL of your endpoint. You can also add a signing secret, so your endpoint can verify that a request really came from Cradl AI, and any HTTP headers your endpoint requires, such as an API key.

The Export to Webhook panel in Cradl AI, with an endpoint URL, a signing secret, HTTP headers and a list of recent runs for test delivery
Configuring a webhook export.

Automating PDF to JSON conversion with webhooks

In many industries, the volume of incoming documents makes manual PDF to JSON conversion impractical. With a webhook export in place, the whole process runs by itself. Here is a quick way to try it:

  1. Visit webhook.site, which auto-generates a unique webhook URL that you can use for testing. Copy it.
  2. Back in Cradl AI, open the “Export to Webhook” panel and paste the URL as the endpoint.
  3. Under “Test delivery”, choose a recent run and click Test webhook. Open View payload to see the JSON that is sent. It contains the extracted value of each field, along with some metadata about the run.
The Export to Webhook panel in Cradl AI showing the JSON payload for a selected run
Previewing the JSON payload before it is sent to your endpoint.

From then on, processed documents are sent to your endpoint as JSON once their values have been validated, by the AI or by a reviewer.

To send PDFs from your own code instead of uploading them by hand, click Add trigger in the builder and choose API. Together with the webhook export, that gives you a PDF-in, JSON-out pipeline without anyone opening the app. The REST API integration page has the details.

Summary

Cradl AI makes it easy to automate PDF-to-JSON workflows by using AI to extract information from PDFs and send structured JSON to any app that supports webhooks.

If your output is tabular rather than nested JSON, the PDF tables to Excel guide walks through the spreadsheet version of the workflow.

Document automation for the agentic era.

Build your first agent in minutes, and let your business users review and train it from day one.