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

FieldValue
MethodPOST
URLhttps://anytomarkdown-pdf-to-markdown-and-document-parser-api.p.rapidapi.com/v1/convert/raw
Send Query ParametersOn. Name fileName, value {{ $binary.attachment_0.fileName }}
Send HeadersOn. X-RapidAPI-Key = your key, X-RapidAPI-Host = anytomarkdown-pdf-to-markdown-and-document-parser-api.p.rapidapi.com
Send BodyOn
Body Content Typen8n Binary File
Input Data Field Nameattachment_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/convert with includeChunks=true instead, then split the chunks array with a Split Out node.
  • Save a file: add Convert to File and write a .md file to Google Drive or S3.

Tips

  • The API detects the format from the file itself; fileName is 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 as url.
Try it without code: the free online converter uses the same engine.Open the converter