N8N workflow - inserting HTML content with formatting into Google Documents

I’m working on an automation workflow where I need to insert HTML content into a Google Doc while preserving all the formatting. My current setup generates content using an AI model, processes it into HTML format, and then tries to add it to a Google document.

The workflow goes like this: AI generates newsletter content → convert to HTML → insert into Google Doc.

I’m using the Google Docs node in n8n and selecting the “insert” operation with “body” as the location and “at end” for positioning. I’ve set the content type to HTML in the configuration.

The problem is that when the content gets added to the document, it shows up as plain text without any formatting. All the HTML tags are visible as text instead of being rendered as formatted content.

Has anyone figured out the correct way to make n8n insert HTML into Google Docs so that the formatting actually works? I have the content available in both HTML and markdown formats if that helps with the solution.

Google Docs API doesn’t handle HTML input - it treats HTML as literal text instead of markup. I hit this same issue last year building something similar. Here’s what worked: parse the HTML first, then use the API’s formatting methods to apply styles programmatically. Extract your text content separately from formatting instructions, insert plain text first, then apply formatting with the API calls for bold, italic, headers, etc. It’s more work than direct HTML insertion, but it’s the only reliable method I’ve found. Converting from markdown might be easier since the formatting rules are simpler to parse.

I encountered a similar issue when I was working with n8n and Google Docs as well. The key thing to keep in mind is that the Google Docs API does not directly support HTML formatting. Instead, it requires structured requests. To resolve this, I implemented a custom function that converts the HTML into the necessary format required by the API. For basic formatting tasks, it helps to use the batchUpdate method to apply formatting after inserting the text. An alternative that worked well for me was to convert the HTML into rich text format before sending it to Google Docs. There are useful npm packages available for that conversion, which can simplify your workflow considerably.

yea, google docs api gets evryone with this one. i used an html parser to break down the content first, then built each batchUpdate request manually for the formatting elements. tedious but reliable. if u know javascript, cheerio’s perfect for parsing html structure so u can loop through and convert it to google’s format.