How to Convert PDF Files into AI-Ready Markdown for Free
A one-call way to turn any PDF into Markdown text your LLM can actually read.
PDFs are everywhere - invoices, research papers, contracts, financial reports, product manuals, scanned forms. They're also one of the worst possible formats to hand to an AI model. A PDF is built for printing, not for reading by a machine. Multi-column layouts, page breaks, footnotes, headers, and tables all get scrambled the moment you try to pull raw text out of them. Feed that mess into an LLM and you get hallucinations, broken tables, and answers that miss half the document.
The fix is to convert your PDF into Markdown first - a lightweight, structured text format that preserves headings, lists, and tables while stripping away the layout noise. This guide shows you how to do exactly that, for free, using Lemino AI's PDF to Markdown API - with up to 5,000 free page conversions to start.
If you've already read our companion guide on converting any URL into AI-ready Markdown, this is the file-based counterpart: same clean output, slightly different flow because you're uploading a document instead of pointing at a live page.
Why PDFs Are So Hard for AI
Before the how-to, it helps to understand why PDFs need a conversion step at all. Plain text extraction tools tend to fail on real-world documents because:
- Reading order is ambiguous. A two-column research paper or a magazine layout has no reliable top-to-bottom flow. Naive extractors interleave the columns and produce gibberish.
- Tables collapse. Financial statements, price lists, and data tables lose their rows and columns, becoming a flat stream of numbers with no meaning.
- Structure disappears. Section headings, bullet points, and hierarchy - the very signals an LLM uses to understand a document - are flattened into one long blob.
- Boilerplate sneaks in. Page numbers, running headers, and footers get mixed into the body text and pollute every chunk you send to your model.
Converting to Markdown solves all four. Headings stay headings, tables stay tables, and the noise gets filtered out - so your model sees the meaning of the document, not its pixels.
Key Features
The PDF to Markdown API is built specifically for document pipelines:
- Page-by-page conversion — every page is processed in order, so long documents stay coherent.
- Tables preserved — tabular content is rebuilt as proper Markdown tables wherever the layout allows.
- Structure intact — headings, lists, and sections carry over faithfully from the source PDF.
- Noise filtering — repeated headers, footers, and boilerplate are stripped automatically.
- Smart chunking — request JSON output and large documents are split into clean, model-sized chunks ready for embedding.
- One simple API call — no SDK, no local PDF library, no headaches. Just an HTTP request.
The Two-Step Workflow
Here's the one real difference from converting a webpage: a URL already lives on the internet, but a PDF sits on your machine. So the flow is upload, then convert.
- Upload your PDF to get a hosted file URL.
- Convert that URL to Markdown with a single call.
That's it. Two requests, and you have clean Markdown.
Quick Start: Try It Free
You can test the converter in your browser with no signup — just drop a PDF on the PDF to Markdown playground. A limited demo quota applies, which is perfect for kicking the tyres before you wire it into code.
When you're ready to automate, grab a free API key from your Lemino settings and use the examples below.
Example API Usage
Each example does the same two things: uploads the PDF, then converts the returned URL to Markdown.
cURL
# 1. Upload the PDF to get a hosted URL
FILE_URL=$(curl -s -X POST https://platform.lemino.ai/upload \
-H "x-api-key: YOUR_API_KEY" \
-H "accept: text/plain" \
-F "[email protected]")
# 2. Convert that URL to Markdown
curl -X GET "https://platform.lemino.ai/api/url2md/$FILE_URL" \
-H "x-api-key: YOUR_API_KEY" \
-H "accept: text/plain"
JavaScript (Fetch)
import fs from 'fs';
const apiKey = 'YOUR_API_KEY';
const headers = { 'x-api-key': apiKey, 'accept': 'text/plain' };
// 1. Upload the PDF to get a hosted URL
const form = new FormData();
form.append('file', new Blob([fs.readFileSync('document.pdf')]), 'document.pdf');
const upload = await fetch('https://platform.lemino.ai/upload', {
method: 'POST',
headers,
body: form,
});
const fileUrl = (await upload.text()).trim();
// 2. Convert it to Markdown
const res = await fetch('https://platform.lemino.ai/api/url2md/' + fileUrl, { headers });
const markdown = await res.text();
console.log(markdown);
Python (requests)
import requests
api_key = 'YOUR_API_KEY'
headers = {'x-api-key': api_key, 'accept': 'text/plain'}
# 1. Upload the PDF to get a hosted URL
with open('document.pdf', 'rb') as f:
upload = requests.post(
'https://platform.lemino.ai/upload',
headers=headers,
files={'file': f},
)
file_url = upload.text.strip()
# 2. Convert it to Markdown
response = requests.get(
f'https://platform.lemino.ai/api/url2md/{file_url}',
headers=headers,
)
print(response.text)
PHP (cURL)
<?php
$apiKey = 'YOUR_API_KEY';
$headers = ['x-api-key: ' . $apiKey, 'accept: text/plain'];
// 1. Upload the PDF to get a hosted URL
$ch = curl_init('https://platform.lemino.ai/upload');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['file' => new CURLFile('document.pdf')]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$fileUrl = trim(curl_exec($ch));
curl_close($ch);
// 2. Convert it to Markdown
$ch = curl_init('https://platform.lemino.ai/api/url2md/' . $fileUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
curl_close($ch);
?>
More examples for Go, Ruby, Java, Kotlin, Swift, C++, and C# are available in the documentation.
Handling Multi-Page PDFs and RAG Chunking
Long PDFs - a 40-page report, a contract, a textbook chapter - are where most converters fall apart. This API processes every page in order, so the Markdown reads top to bottom exactly like the source.
For RAG (Retrieval-Augmented Generation) pipelines, you usually don't want one giant blob of text - you want sensible chunks to embed and store in a vector database. Switch the response format to JSON and large documents are split into intelligent chunks automatically:
'accept': 'application/json'
Each chunk respects the document's structure, so you avoid the classic mistake of slicing a table or a heading in half. Drop the chunks straight into your embedding step and you're done.
What About Tables and Scanned PDFs?
Two questions come up constantly, so here's the straight answer:
- Tables are reconstructed into Markdown tables wherever the original layout makes it possible - ideal for invoices, financial statements, and data sheets.
- Scanned PDFs (image-only documents with no embedded text) are not OCR-processed. The converter works best with text-based PDFs. If your file is a scan, run it through an OCR step first, then convert the resulting text-based PDF.
Real-World Use Cases
Once your PDFs are Markdown, a lot of things get easier:
- Document Q&A chatbots - let users ask questions against manuals, policies, or research papers.
- RAG knowledge bases - embed clean, chunked content instead of noisy raw text.
- Invoice and contract parsing - pull structured tables and clauses into your data pipeline.
- Research summarization - feed academic PDFs to an LLM without the column-scramble problem.
- Internal search - index your document library as searchable, structured text.
Frequently Asked Questions
Does it convert multi-page PDFs?
Yes. Every page is processed and returned in order, with intelligent chunking available through the JSON output.
Are tables preserved?
Yes. Tabular content is converted into Markdown tables wherever the source layout allows.
What about scanned PDFs?
It works best with text-based PDFs. Scanned, image-only PDFs are not OCR-processed, so run OCR first if your document is a scan.
Is it really free?
You can try it in the browser with no signup, and an API key gives you up to 5,000 free conversions to start.
Can I convert other file types too?
Yes — the same platform handles URLs, Word, PowerPoint, Excel, Image, and more.
Why This Matters
Whether you're building a chatbot, a RAG system, a document pipeline, or a knowledge base, the quality of your output depends entirely on the quality of your input. Garbage layout in means garbage answers out. Converting your PDFs to clean, structured Markdown first means your model spends its attention on the content, not on untangling the formatting.
Get Started
Grab a free API key and convert your first PDF in minutes: