How to Insert Rich Formatted Text into a Word Template Placeholder?

Hi,

I’m generating a Word document in n8n from a template with placeholders like:

{{text}}

I need to replace them with rich formatted text (bold, paragraphs, line breaks, bullet points), not just plain text.

What is the correct way to inject formatted content into a Word template placeholder in n8n?

Hi @n8ndev123, hope you’re doing well!
This is a very common question, and I’ve found it can be tricky because template placeholders usually expect simple strings rather than structured rich text. When I use the Google Docs node to generate Word files, it typically treats everything as plain text by default. One thing I sometimes try is converting Markdown to HTML using the Markdown node, since some nodes can interpret basic HTML tags, although Word templates can be a bit strict about that. If I need more precise control over paragraphs or bullet points, I may use a Code node to structure the data and split the content into multiple smaller placeholders like {{bullet1}}, {{bullet2}}, filling them with logic instead of relying on a single large placeholder. For more complex formatting, I also consider dedicated templating services such as APITemplate.io or Bannerbear, since they are designed to inject HTML or CSS-style formatting into document templates and tend to integrate well with n8n; ultimately, I just try to balance the complexity of the text with the limitations of the template engine. :blush:

1 Like

Hi,

Thanks a lot for your detailed answer, I really appreciate the time you took to explain the different approaches :folded_hands:

However, what I’m trying to achieve is slightly different — I specifically need to inject dynamically generated rich text (with formatting like bold, paragraphs, bullet points, etc.) into a single placeholder inside a Word template, rather than splitting the content into multiple predefined placeholders.

Have you ever worked with Docxtemplater for this use case? https://www.npmjs.com/package/n8n-nodes-docxtemplater

I’m wondering whether using its HTML module would be the proper way to handle formatted content injection inside n8n.

Would love to hear your thoughts :slightly_smiling_face:

Honestly plain placeholder replacement in .docx won’t do rich text, those placeholders are just string swaps. You’d need something like docx-templater’s HTML module to actually inject formatted content into the XML structure of the Word file. Easiest way in n8n is a Code node with the docxtemplater and docxtemplater-html-module npm packages, or offload it to an external API like Carbone or DocuGenerate.

1 Like

thank you for the kind words @n8ndev123

I don’t have hands-on experience with Docxtemplater, so I can’t speak from direct implementation. That said, if your goal is to inject dynamically generated rich text into a single placeholder, the general approach that has worked for me in similar situations is to generate the formatted structure first, usually as HTML or structured text in a Code node, and then pass that content into the document generation step. From what I’ve read about Docxtemplater it does seem like it was designed exactly for this kind of use case, So if is supported in your workflow, it could indeed be the right direction for handling rich text injection. I haven’t tested that package myself in n8n yet, but conceptually it aligns well with the requirement of inserting formatted content into a single placeholder. If you do try it, I’d be very interested to hear how it works in practice.

1 Like

Thanks !

docx-templater’s HTML module isn’t free, am I right ?

Thank you for youtr help :slightly_smiling_face:

1 Like