File Conversion to Markdown for LLM Preparation using Datalab.to - n8n Workflow

Convert PDFs, DOCs, and images to Markdown automatically using this n8n workflow. Ideal n8n templates for RAG and AI preparation via the Datalab.to API.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Users needing to prepare proprietary documents (PDF, DOC) or images for use in Large Language Models (LLMs).

  • Technical content creators seeking robust document preprocessing solutions.

  • Developers looking for powerful n8n templates to handle complex document conversion tasks.

  • Anyone building a RAG (Retrieval Augmented Generation) system that requires standardized input.

Overview

Preparing diverse data sources for use with modern AI tools often requires converting documents like PDFs and DOCX files into clean, structured text formats like Markdown. This essential n8n workflow streamlines that process by utilizing the Datalab.to API. The automation starts with a user-friendly upload interface, managed by an n8n trigger, and handles the conversion, polling, and final data extraction.

This specific n8n template is highly valuable for those working on RAG systems, ensuring consistent, high-quality input for generative AI models. Every n8n node in this flow is configured to maximize efficiency, allowing you to convert documents and images automatically, freeing up time typically spent on manual data cleaning. Leverage the power of n8n to simplify your data pipeline.

How it Works

This powerful n8n workflow operates in five core stages, starting with the data input and concluding with the extracted Markdown content.


  1. Input Trigger: The process begins with the 'On form submission' n8n trigger. This node creates a public form interface where users can upload documents (PDF, DOC, or images) to initiate the conversion sequence.

  2. API Submission: The uploaded file is immediately routed to the 'Send to Datalab API' n8n node, which uses an HTTP Request to POST the file to Datalab.to's marker endpoint. The configuration specifies that the output format must be markdown and leverages the LLM processing features of the API. This initial request returns a URL to check the processing status.

  3. Wait Period: Recognizing that file processing is asynchronous, the workflow enters a 'Wait' n8n node, pausing for 10 seconds before proceeding. This is crucial for giving the Datalab service time to complete the heavy lifting.

  4. Polling for Results: The 'Get Markdown' n8n node then executes a GET request, dynamically using the check URL returned in the previous step ({{ $json.requestcheckurl }}). This n8n node retrieves the processed data, which includes the final Markdown content.

  5. Data Standardization: Finally, the 'Set Fields' n8n node isolates the extracted Markdown content ({{ $json.markdown }}) from the API response payload, preparing the clean, standardized text for downstream processes or other n8n templates.

Installation Guide

To deploy and utilize this n8n workflow effectively, follow these setup instructions:


  1. Import the n8n Workflow: Copy the provided JSON code and paste it into your n8n instance using the 'New' > 'Import from JSON' option.

  2. Datalab.to Account: Sign up for an account at Datalab.to to obtain your API key.

  3. Credential Setup: In n8n, you need to create a Generic HTTP Header credential:

Go to Credentials and create a new one for 'HTTP Header Auth'.
Set the Header Name to X-API-Key.
Paste your Datalab API Key into the Header Value field.
Assign this credential to both the 'Send to Datalab API' and 'Get Markdown' n8n node configurations.

  1. Activate the Trigger: Click on the 'On form submission' n8n trigger node and copy the form URL to begin testing your file uploads.

  2. Save and Activate: Save the n8n template and toggle the workflow to 'Active' to enable automated processing.

Node Details

On form submission (n8n trigger):
Function: Acts as the starting point, providing a web interface for file uploads.
Key Configuration: Requires a single, mandatory file upload field. This is the initial n8n trigger that captures the source document.
Send to Datalab API (n8n node):
Function: Sends the uploaded file binary data to Datalab.to for conversion.
Key Configuration: Method is POST, Content Type is multipart-form-data. Body parameters specify outputformat: markdown and usellm: true for enhanced extraction.
Wait (n8n node):
Function: Pauses the n8n workflow execution for a fixed period to allow for external processing.
Key Configuration: Amount set to 10 seconds. Increase this wait time if processing exceptionally large documents.
Get Markdown (n8n node):
Function: Polls the Datalab.to endpoint to retrieve the completed Markdown result.
Key Configuration: URL is dynamically set using expression ={{ $json.requestcheckurl }} based on the previous API response. Uses Generic HTTP Header Authentication.
Set Fields (n8n node):
Function: Cleans up the final output, isolating only the generated Markdown text.
* Key Configuration: Creates a new field named markdown and assigns the value ={{ $json.markdown }} from the retrieved data.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by

Automation expert specializing in building smart, scalable workflows using tools like n8n, Make, and Airtable. I help businesses save time, reduce manual work, and grow faster with tailored automation solutions. Feel free to reach out at [email protected] to discuss your project. I am also on x.com/juppfy

Featured*