PDF extraction

Best PDF to Markdown Converter Tools in 2026

Discover the best pdf to markdown converter methods for developers. Explore APIs like OkraPDF, CLI tools like Pandoc, and advanced document handling.

May 19, 2026 13 min read OkraPDF
pdf to markdown converterpdf to markdownpandocpdf apideveloper tools

You usually find out you need a pdf to markdown converter when the simple path has already failed. You extracted raw text from a PDF, sent it into a search index or an LLM pipeline, and got back garbage reading order, broken tables, missing headings, and way too many tokens. Or you tried a local script that worked on one clean report and fell apart on the first scanned bank statement or two-column whitepaper.

Markdown sits in a useful middle ground. It's lighter than HTML, more structured than plain text, and much easier to move through developer workflows than the PDF itself. That makes it a good normalization format when you need one document representation that can feed documentation systems, knowledge bases, search, and downstream AI.

Table of Contents

Why Convert PDF to Markdown

A common failure case looks like this: a team gets a 200-page PDF manual, extracts raw text, sends it into a search or LLM pipeline, and then spends hours fixing broken headings, merged table cells, and image captions that landed in the wrong place. The problem is not just file format preference. PDF preserves presentation. Markdown preserves structure in a form developers can use.

A diagram illustrating four key benefits of converting PDF documents into the Markdown file format.

Markdown keeps the parts that matter

For engineering and documentation workflows, the benefit is structured text with far less noise than HTML and far more context than plain text. Headings, lists, links, emphasis, and code blocks can survive conversion in a format that is easy to diff, chunk, store in Git, and pass into downstream tooling.

That structure helps in AI and search pipelines too. Converting a PDF into clean Markdown can reduce unnecessary tokens compared with sending raw page text or bloated HTML, while keeping the document hierarchy intact. In practice, that means better chunk boundaries, cleaner retrieval, and less cleanup before summarization or extraction.

Parser choice affects the result as much as output format. A simple digital PDF with clean reading order may convert well with almost any tool. A quarterly report with nested tables, callout boxes, and sidebars will expose weak parsers fast.

Practical rule: If the next step is search, chunking, summarization, or extraction, plain text usually loses too much structure and HTML often adds too much noise. Markdown is usually the safer default.

Where it fits in a real pipeline

Markdown integrates well with more than AI workflows. Engineering teams use it to republish PDFs into docs sites, store versioned content in Git, and normalize mixed document inputs before indexing or analysis. If your pipeline also needs structured fields beyond Markdown, broader PDF extraction workflows often make more sense than treating conversion as a one-off export.

Three workflows cover most production cases:

  • API-based conversion fits apps and automated pipelines that need stable output, retries, and throughput.
  • CLI-based conversion fits local scripts, batch jobs, and environments where keeping files on your own machine matters.
  • Specialized parsers with OCR fallback fit messy documents, scanned pages, image-heavy layouts, and PDFs where table structure or reading order cannot be guessed reliably.

The hard part is rarely "PDF to Markdown" in the abstract. It is deciding how to handle bad tables, embedded images, two-column layouts, and scanned pages before those problems hit production.

Method 1 API-Based Conversion with OkraPDF

If you're building this into an app, an API is usually the fastest path from upload to usable Markdown. You don't want every service in your stack re-downloading files, shelling out to local binaries, and reinventing file state.

A person coding on a laptop to use the OkraPDF API for converting PDF files into markdown format.

Why an API is the default choice for apps

The main advantage is operational, not philosophical. You upload once, keep a stable file reference, and use that reference in later extraction or conversion calls. That pattern is cleaner for queues, retries, webhooks, and audit trails than passing around temp files.

It also maps well to adjacent document workflows. A hosted file can support sharing, previews, extraction, and downstream processing from the same source object. If your app already needs structured outputs beyond Markdown, it's worth looking at broader PDF extraction workflows instead of treating conversion as a dead-end step.

Step 1 upload the PDF

A common first step is to host the PDF and get back a file_id you can reuse.

curl -X POST "https://api.okrapdf.com/v1/files" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@./document.pdf"

In a typical response, you'd store the file_id and the hosted URL in your database so later jobs can reference the same document.

For a Node app, the shape is usually similar to this:

import fs from "node:fs";
import FormData from "form-data";
import fetch from "node-fetch";

const form = new FormData();
form.append("file", fs.createReadStream("./document.pdf"));

const uploadRes = await fetch("https://api.okrapdf.com/v1/files", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OKRAPDF_API_KEY}`,
  },
  body: form,
});

const uploaded = await uploadRes.json();
console.log(uploaded.file_id);

Step 2 request Markdown output

Once you have a file_id, the conversion call becomes straightforward. That's the happy path you want in production. Keep the upload boundary separate from the conversion boundary so you can retry each independently.

curl -X POST "https://api.okrapdf.com/v1/convert/markdown" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "file_id": "YOUR_FILE_ID"
  }'

A JavaScript version looks like this:

const convertRes = await fetch("https://api.okrapdf.com/v1/convert/markdown", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OKRAPDF_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    file_id: uploaded.file_id,
  }),
});

const markdown = await convertRes.json();
console.log(markdown);

The API path is strongest when your app needs consistency more than tinkering. It gives you a stable integration surface, and your team can spend time validating outputs instead of maintaining local conversion environments.

A few things still break the happy path. Complex tables, image-only scans, and multi-column layouts can all produce uneven Markdown if the parser isn't matched to the document. That's why API speed alone isn't enough. You still need routing logic and fallback behavior for hard documents.

Method 2 Command-Line Conversion with Pandoc

Pandoc remains the tool a lot of developers reach for first because it's local, scriptable, and easy to put inside shell workflows. If your main goal is “turn this report into a Markdown file on my machine,” it's still a reasonable starting point.

Screenshot from https://pandoc.org/demos.html

Why developers still like the CLI path

The command is simple:

pandoc input.pdf -t markdown -o output.md

That works well in local automation, CI jobs, and privacy-sensitive environments where you don't want to upload files to a hosted service. It's also easier to inspect intermediate files when debugging conversion problems.

The broader ecosystem around PDF-to-Markdown has also matured quickly. The open-source project Marker says it converts PDFs and other formats into Markdown and reports favorable benchmark results versus cloud services, while projecting 25 pages per second on an H100 in batch mode in its Marker project documentation. That tells you the category isn't experimental anymore. Open-source options have become serious enough for real pipelines.

Where Pandoc starts to struggle

Pandoc is best when the source PDF already behaves like a document instead of a visual layout. Text-heavy reports, papers, and manuals are the safer use case. The moment the file depends on columns, floating callouts, embedded charts, or scanned pages, you're asking a general converter to reconstruct structure that may not exist explicitly.

A quick rule of thumb:

  • Use Pandoc first for developer docs, reports, and simpler academic PDFs.
  • Switch tools when tables matter, when the reading order is wrong, or when the PDF is mostly images.
  • Keep processing local if privacy is the priority and your team can tolerate more tuning.

CLI conversion gives you control over the environment. It doesn't guarantee control over the document's structure.

That's the trade-off. Local processing is great. But local processing on the wrong parser still gives you bad Markdown.

Handling Complex PDFs Tables Images and Code

Most conversion demos use documents that are polite. Real PDFs aren't. They contain tables made from positioned text, screenshots with captions, sidebars, footnotes, syntax-highlighted code, and layouts that don't map cleanly to a linear text format.

Community benchmarking around Marker and Nougat shows why this matters in production. Users reported that Marker could extract more text and finish faster, while Nougat sometimes ran into out-of-memory failures on long or math-heavy PDFs, according to this community discussion of parser behavior. The practical lesson from those reports is simple: use a fast structure-aware parser first, then fall back to OCR only when needed.

Tables are the first thing to break

A table in a PDF usually isn't a table in the semantic sense. It's often just text placed at coordinates. That's why one converter preserves rows correctly while another collapses everything into a paragraph.

What tends to work:

  • Simple tables often survive into GitHub Flavored Markdown if the parser understands alignment and cell boundaries.
  • Dense financial tables usually need a parser that explicitly models structure, not just text order.
  • Merged cells and nested headers often don't belong in Markdown at all. In those cases, preserve the table separately or route it to structured extraction.

If a table has to be machine-readable later, don't judge the converter by how pretty the Markdown looks. Judge it by whether the rows and headers still mean the same thing.

If your end goal is analysis rather than display, a Markdown table may be the wrong target. That's where parser selection matters more than output format. A deeper walkthrough on extracting data from PDFs with Python is more relevant when you need rows you can trust.

Images need a file strategy

Markdown can reference images, but it doesn't solve image extraction for you. You need a predictable rule for where extracted assets live and how links get written.

Good pipelines usually do one of these:

  1. Export images to a sibling folder and rewrite Markdown references relative to the .md file.
  2. Upload extracted assets to object storage and insert absolute URLs.
  3. Drop purely decorative images if the output is meant for retrieval or summarization instead of republishing.

If the point of conversion is AI analysis, preserving every figure as an image link may not help much. What usually matters more is keeping captions near the right surrounding text. That's also where broader document workflows overlap with AI for turning text into insights, especially when converted content feeds extraction, search, or review systems.

Code blocks need reading order to survive

Code samples are fragile because indentation and sequence matter. A parser can technically extract every token and still ruin the snippet by flattening whitespace or inserting line breaks in the wrong place.

For code-heavy PDFs:

  • Prefer fenced code blocks in the Markdown output.
  • Validate indentation on a sample set before batch conversion.
  • Watch multi-column layouts closely, because they often scramble code lines with surrounding body text.

“More text extracted” isn't always “better output.” A smaller, cleaner result usually beats a noisy full dump.

When to Use OCR for Scanned Documents

Some PDFs contain text. Others contain pictures of text. If selecting and copying from the document gives you nothing useful, you're not doing text extraction anymore. You're doing OCR.

How to tell when OCR is required

Three signs usually show up fast:

  • Copy-paste fails or returns gibberish.
  • Search inside the PDF finds nothing even though the page looks readable.
  • The document came from scans, faxes, or phone captures and the page is basically an image.

Once OCR enters the pipeline, your trade-offs change. Throughput drops, errors increase, and layout reconstruction becomes much harder. That's why production systems should only invoke OCR when they need it, not as the default for every file.

If you want a quick way to sanity-check a scan before integrating a full workflow, a lightweight online OCR tool can help confirm whether the document has readable text at all. It's useful for debugging edge cases, especially when a customer upload looks fine to a human but fails parser-side.

What a production OCR path should optimize for

The best OCR workflow is selective. Run a structure-aware parser first. If it finds a good text layer, stop there. If not, send the file through OCR and then normalize the result into Markdown.

Recent research also points to ways of making the generation step faster after extraction. A paper on lookup-based decoding reports that Copy Lookup Decoding accelerated end-to-end PDF-to-Markdown conversion by up to 1.70× at original quality by reusing candidate n-grams from the source PDF during generation, as described in the CLD paper on arXiv. For production systems, that's a useful reminder that OCR cost isn't the only performance variable. The Markdown generation step can be optimized too.

OCR should be a fallback, not a reflex. Every scanned page you process adds latency and another chance for structural errors.

For teams that regularly deal with scans, receipts, or image-based filings, it helps to centralize OCR behind a dedicated workflow such as an OCR tool for PDF documents. The main operational win is consistency. You don't want every service guessing differently about when a file needs OCR.

Choosing Your Method and Best Practices

A team usually figures this out after the first messy batch lands in production. Ten sample PDFs convert fine on a laptop. Then customer uploads start arriving with merged table cells, scanned signatures, missing text layers, and image-heavy pages. At that point, the key question is not how to convert PDF to Markdown. It is how much control you need when the input quality drops.

If you convert a handful of clean files locally, a CLI is usually enough. If you are building document intake into a product, an API path with predictable file references, retries, and parser routing is preferable. If your queue includes scans, financial statements, or records that trigger privacy review, the workflow around conversion matters as much as the converter itself.

A comparison chart highlighting the differences between API-based OkraPDF and CLI-based Pandoc for PDF to Markdown conversion.

A practical decision rule

Use caseBetter fit
One-off local conversionPandoc or another CLI
App feature with repeated uploadsAPI-based conversion
Sensitive files with strict residency needsLocal processing or tightly controlled API deployment
Layout-heavy or scan-heavy inputsSpecialized parser with OCR fallback

Best practices before you commit

Test against the files your team dreads, not the ones that make the demo look good. The worst documents expose where tables break, where images lose context, and where code blocks or numbered clauses collapse into plain text.

Treat Markdown as an intermediate format when the goal is downstream extraction, search, or publishing. It is readable, diffable, and easy to feed into later steps, but it is still a lossy representation for complex layout. That trade-off is fine if you accept it early and validate the output against your actual use case.

Plan for privacy review early. Public converter tools often prioritize convenience while leaving retention and logging unclear. That becomes a real problem for legal, healthcare, and finance teams, as discussed in this review of privacy issues in PDF to Markdown converters.

Keep adjacent conversions in mind. Tools like Dokly's OpenAPI converter show the same broader pattern where Markdown works well as a normalization layer across very different source formats.

The best pdf to markdown converter is the one that fits your document mix, fails in predictable ways, and matches how your team ships and debugs software.

If you want a faster way to test PDF workflows in a real app, OkraPDF is a good place to start. You can host a PDF, get a reusable file reference, and build from there without bolting together separate upload and processing systems.