n8n: convert PDF and Word attachments to Markdown
Turn PDF and Word e-mail attachments into Markdown for an AI agent or vector store with one HTTP Request node.
This guide turns every PDF or Word attachment you receive into clean Markdown inside n8n, ready for a vector store or an AI agent. It uses the AnyToMarkdown API and one HTTP Request node.
What you need
- An n8n instance (cloud or self-hosted)
- A RapidAPI key (the free plan on AnyToMarkdown is enough to try it)
1. Get the file
Add a trigger that produces binary data, for example Gmail Trigger with Download Attachments switched on. The first attachment arrives in the binary field attachment_0.
2. Convert it with an HTTP Request node
| Field | Value |
|---|---|
| Method | POST |
| URL | https://anytomarkdown-pdf-to-markdown-and-document-parser-api.p.rapidapi.com/v1/convert/raw |
| Send Query Parameters | On. Name fileName, value {{ $binary.attachment_0.fileName }} |
| Send Headers | On. X-RapidAPI-Key = your key, X-RapidAPI-Host = anytomarkdown-pdf-to-markdown-and-document-parser-api.p.rapidapi.com |
| Send Body | On |
| Body Content Type | n8n Binary File |
| Input Data Field Name | attachment_0 |
Run the node. The response is the document as Markdown text, in {{ $json.data }}.
3. Use the Markdown
- AI agent or LLM node: pass
{{ $json.data }}as context. - Vector store: call
/v1/convertwithincludeChunks=trueinstead, then split thechunksarray with a Split Out node. - Save a file: add Convert to File and write a
.mdfile to Google Drive or S3.
Tips
- The API detects the format from the file itself;
fileNameis only a hint. - It also converts XLSX, PPTX, HTML, e-mails (
.eml,.msg) and images. - If you see
file_too_large, the file exceeds your plan's limit. Upgrade the plan or pass the file's public link asurl.
Try it without code: the free online converter uses the same engine.Open the converter