Automate PDF to HTML Conversion with n8n and Google Drive

Save hours by automatically converting newly uploaded PDFs in Google Drive to HTML files using n8n automation. This workflow streamlines document handling without manual effort.
googleDriveTrigger
if
httpRequest
+3
Learn how to Build this Workflow with AI:
Workflow Identifier: 1588
NODES in Use: Google Drive Trigger, If, HTTP Request, Code, Google Drive, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Sarah, a content manager at a digital publishing company. Every day, she receives numerous PDFs containing newsletters, reports, and articles that need to be converted into HTML format for her company’s website. Manually downloading each PDF from Google Drive, converting them, and re-uploading the HTML files wastes her hours daily. Additionally, errors occur during manual conversion, causing inconsistent web page formatting that frustrates her team and delays content publication.

This manual process costs Sarah at least two hours each workday and increases the risk of human errors that affect the quality and timeliness of published content. She needs an automated, error-free way to convert PDFs to HTML the moment they are uploaded to Google Drive.

2. What This Automation Does

This n8n workflow automates the entire process of converting PDFs to HTML as soon as they are uploaded to a specific Google Drive folder. Here’s what happens when this workflow runs:

  • Monitors a designated folder in Google Drive and triggers on every new PDF file added.
  • Checks file type to ensure only PDFs are processed, avoiding errors and unnecessary operations.
  • Sends the PDF file link to a dedicated PDF conversion API that transforms the file into HTML format.
  • Processes the HTML response by converting it into a binary file compatible with Google Drive storage requirements.
  • Uploads the newly created HTML file back into a specified Google Drive folder, keeping the directory organized and updated.
  • Eliminates manual steps, saving Sarah over 10 hours a week, and reduces the chance of conversion errors.

3. Prerequisites ⚙️

  • Google Drive account with access to the folder you want to monitor and store files.
  • Access to n8n automation platform (cloud or self-hosted). You can host n8n yourself via options like Hostinger for more control.
  • API credentials for PDF.co (or a similar PDF to HTML conversion API) to enable file conversion via HTTP Request node.
  • Setup OAuth2 credentials for Google Drive in n8n to enable file monitoring and uploading.

4. Step-by-Step Guide

Step 1: Setup Google Drive Trigger Node

Navigate to Nodes → Add Node → Google Drive Trigger. Configure it to watch the specific folder where PDFs will be uploaded.

In the Parameters, select Event: fileCreated, set Trigger On to specificFolder, and provide the folder’s URL or ID.

This node polls the folder every minute for any newly created files.

Tip: Make sure the OAuth2 credentials for Google Drive are set correctly in Credentials. Otherwise, the node won’t authenticate.

Step 2: Add an If Node to Filter PDFs

After the trigger, add an If node. This node checks if the uploaded file is a PDF by verifying the MIME type.

Set the condition as: {{ $json.mimeType }} === 'application/pdf' with case sensitivity enabled.

If the condition is true, the workflow continues; otherwise, it stops to avoid unnecessary processing.

Step 3: Configure HTTP Request Node for PDF to HTML Conversion

Add an HTTP Request node next. Configure it as follows:

  • Method: POST
  • URL: https://api.pdf.co/v1/pdf/convert/to/html
  • Authentication: Use HTTP Header Auth with your PDF.co API key.
  • Body Parameters (JSON): Include the link to the PDF using {{ $json.webViewLink }}, and other optional parameters like inline=true, async=false, pages=0-, and specify the output file name.

This node sends the PDF file’s URL to the PDF.co API which returns the converted HTML contents.

Step 4: Convert HTML String to Binary File Using Code Node

Add a Code node to convert the HTML string response into a binary format compatible with Google Drive’s upload requirements.

Copy and paste this JavaScript code:

// Convert the HTML string to a Buffer
const buffer = Buffer.from($json.body, 'utf-8');

// Return the buffer as binary data
return [
  {
    binary: {
      data: {
        data: buffer.toString('base64'), // Convert buffer to base64 string
        mimeType: 'text/html',
        fileName: 'sample.html'
      }
    }
  }
];

This transformation prepares the file for upload in the next step.

Step 5: Upload HTML File Back to Google Drive

Add a Google Drive node to upload the converted HTML file.

Configure it with:

  • Target folder ID or URL where the HTML file should be stored.
  • Filename: e.g., sample.html.
  • Link the binary data output from the Code node into this node.

Once configured correctly, the newly converted HTML file will appear in Google Drive automatically.

Step 6: Add Sticky Notes for Workflow Documentation (Optional but recommended)

Use Sticky Note nodes to add descriptions, instructions, or any relevant notes within your n8n workflow. This helps future you or collaborators understand the process flow.

5. Customizations ✏️

  • Change Output Filename: Modify the filename in the Code node’s JavaScript to dynamically name files based on original PDF names.
  • Convert to Other Formats: Replace or add HTTP Request nodes to convert PDF to other file formats such as DOCX or TXT using suitable APIs.
  • Folder Organization: Change Google Drive node folder parameters to save HTML files in subfolders based on upload date or file tags.
  • Batch Processing: Adjust trigger polling interval or add batch loops to process multiple PDFs in one run.

6. Troubleshooting 🔧

Problem: “Invalid OAuth credentials” error in Google Drive nodes.
Cause: Expired or incorrectly configured Google OAuth2 credentials.
Solution: Reauthorize the Google Drive OAuth2 credential in n8n by navigating to Credentials and refreshing the token.

Problem: HTTP Request node returns 401 Unauthorized.
Cause: Incorrect or missing API key for PDF.co.
Solution: Verify your PDF.co API key, update the HTTP Header Auth credentials, and test again.

Problem: Converted HTML doesn’t appear in Google Drive.
Cause: Binary data not properly formatted or missing in Google Drive node.
Solution: Ensure the Code node outputs binary with the correct MIME type and filename, then link it to the Google Drive upload node’s binary input.

7. Pre-Production Checklist ✅

  • Verify Google Drive OAuth2 credentials and permissions.
  • Test uploading a sample PDF to the watched folder to trigger the workflow.
  • Confirm HTTP Request node successfully converts PDF to HTML via API response.
  • Check Code node outputs proper binary data with the right MIME type.
  • Ensure the Google Drive node uploads files to the correct folder and filename.
  • Add logging or execute test runs in n8n to monitor for any errors before full deployment.

8. Deployment Guide

Once all tests pass, activate the workflow by toggling the Active switch.

Monitor the first few executions to ensure files convert and upload correctly.

Use n8n’s execution logs for troubleshooting if needed.

9. FAQs

Q: Can I use another PDF conversion API instead of PDF.co?
A: Yes, replace the HTTP Request node’s URL and authentication with your preferred API, ensuring it accepts PDF URLs and returns HTML.

Q: Does this workflow consume API credits?
A: The PDF conversion API usage depends on your PDF.co plan and can affect API call limits.

Q: Is my Google Drive data safe?
A: n8n uses OAuth2 secure authentication; ensure your credentials are kept safe and do not share access publicly.

10. Conclusion

By setting up this automated PDF to HTML conversion workflow, you’ve significantly reduced manual labor and sped up your content publishing process. This automation saves over 10 hours weekly while improving consistency and organization of your web-ready documents.

Next, consider automating notifications for converted files or integrating this flow with a CMS for immediate publishing. You could also extend this to batch process archived PDFs.

You’ve taken a solid step towards smarter document handling with n8n and Google Drive—well done!

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free