Questions

How do you convert PDFs to Markdown and JSON for AI agents and RAG?

In short

In three steps: read the document structurally (text, tables, headings, positions), produce Markdown for running text and JSON for fixed fields, and verify the result against the original. What matters is that every element keeps its source location – otherwise neither a human nor an agent can back up an answer later.

Markdown or JSON?

Markdown suits running text and context for RAG systems: headings, lists and tables survive as structure. JSON suits fixed fields – amounts, dates, parties, line items – with a schema that defines required fields and data types. Often you need both.

The steps

Common mistakes

Tables end up as running text in the Markdown. Headers and footers repeat in every section. Page breaks tear tables and sentences apart. And when splitting into chunks for RAG, the link to the heading is lost.

Tools

There are open-source tools that run locally and cloud services for extraction. For confidential documents, what matters most is where processing happens – and whether the result is verified to be complete. See verifying completeness.

More questions