I’m working on an n8n workflow where I need to insert HTML content into a Google Doc while preserving the formatting. My current setup generates a newsletter using an AI model, then converts it to both markdown and HTML formats before sending it to Google Docs.
The workflow goes like this: AI generates content → convert to HTML/markdown → insert into Google Doc
In my Google Docs node configuration, I’m using the insert operation with these settings:
- Location: end of document body
- Content type: HTML
- Input: the generated HTML content
However, when the content gets inserted into the document, all the HTML formatting gets stripped out and it appears as plain text. The bold text, headers, and other styling elements don’t show up properly.
I have the content available in both HTML and markdown formats if that helps. What’s the correct way to insert formatted HTML content into Google Docs through n8n so that the styling is preserved?
Google Docs API strips formatting when you insert HTML directly - ran into this same issue last year with my automation setup. Here’s what worked: Skip raw HTML and use batch update requests instead. Parse your HTML content and convert each element to Google Docs API calls. Bold tags become textStyle updates with bold: true, etc. Even better solution - add Google Apps Script as a middle step in your n8n workflow. It handles the HTML parsing and applies formatting through built-in methods way cleaner. Actually, markdown might be your best bet since it converts to structured data that maps directly to Google Docs formatting calls.
Had the same exact issue with my automated reports. The Google Docs node in n8n doesn’t handle HTML right - it just dumps it as plain text instead of actually formatting it. I fixed this by ditching the built-in node and using the Google Docs API’s documents.batchUpdate method through n8n’s HTTP Request node instead. You’ll have to parse your HTML into separate formatting requests first though. Another trick that worked really well - upload your HTML as a file to Google Drive, then convert it to Docs format. The conversion keeps most of the formatting that direct insertion kills. Extra step, but way cleaner results.
yeah, i had a similar issue. try converting ur html to rich text. it seems like google docs api struggles with plain html. some folks swear by markdown too. just experiment a bit to see what fits best for ur workflow!
This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.