Is it possible to build document translation workflow that generates translated file?

Hey All :waving_hand:

I’ve got a question regarding building a translation workflow.

Is it possible to build a workflow in n8n that fetches files, e.g. by default I think they are fetched in bin format but I used code node to transform them into the docx format, the files would be downloaded via an API we have and fed into the ai agent node to translate their content into a different language and then recreate the file, the docs file let’s say in the same format, structure, table format, fonts etc., preserving all the headings, tables and their content etc., But with translated content?

How should I approach this?

I feel like I’m stuck here.

Thanks in advance!

Hi @oesterreicher-0417
These may help. Discover 10649 Automation Workflows from the n8n's Community

1 Like

Yes, it is possible, but the difficult part is not the translation itself.

The difficult part is recreating the DOCX while preserving exactly the same formatting, tables, headings, fonts, runs, styles, images, headers, footers and page structure.

I would not send the complete binary DOCX directly to an AI Agent and expect it to return the same document translated. The AI should only translate the extracted text. The document structure should be handled separately and deterministically.

The workflow should be something like this:

Download file → Parse DOCX structure → Extract translatable text → Translate in controlled chunks → Validate translations → Replace text inside the original DOCX structure → Generate translated DOCX → Upload or return file

n8n can receive and work with files as binary data, and its file nodes can extract supported binary formats into JSON or convert structured data back into files. However, converting extracted text back into a generic file will not automatically rebuild an original DOCX with the exact same formatting. (docs.n8n.io)

For DOCX files specifically, I would use a dedicated document-processing service or library rather than trying to do everything directly inside the AI Agent.

For example:

  1. Download the DOCX through your API.
  2. Send the binary file to a small Python service using python-docx, or another DOCX-processing library.
  3. Extract paragraphs, table cells, headers, footers and text runs while assigning each one a stable ID.
  4. Send only the text and IDs to the translation model.
  5. Require structured JSON output such as:
[
  {
    "id": "paragraph_12_run_3",
    "translatedText": "Translated content"
  }
]
  1. Match every translated value back to its original ID.
  2. Replace only the original text nodes while leaving the styles and document structure untouched.
  3. Save the modified package as a new DOCX file.
  4. Return it to n8n as binary data and upload it to your destination.

I would probably not use an AI Agent for the core translation unless the translation requires tools or decision-making. A normal LLM chain or direct model/API call is easier to control and produces more predictable structured output.

You also need to be careful with text runs. In DOCX, one sentence can be divided into multiple runs because one word is bold, another is italic or part of a hyperlink. Translating each run independently can destroy the sentence. Translating the whole paragraph can preserve meaning but make it harder to restore the exact inline formatting.

So you need to decide what matters more:

  • exact translation quality,
  • exact inline formatting,
  • or a balance between both.

For a production workflow, I would also add:

  • document language detection,
  • chunking based on paragraphs and table cells,
  • glossary and terminology rules,
  • protection for URLs, numbers, codes and placeholders,
  • validation that every source ID received one translation,
  • retry handling,
  • translated-document quality checks,
  • and a manual review path when the document structure cannot be safely reconstructed.

If the documents are simple, such as paragraphs and basic tables, python-docx should be enough.

If they contain advanced Word features such as text boxes, complex layouts, tracked changes, fields, SmartArt or embedded objects, python-docx may not preserve everything correctly. In that case, I would either manipulate the DOCX XML package directly or use a document-translation API that officially supports DOCX layout preservation.

So yes, n8n can orchestrate the complete workflow, but I would treat n8n as the orchestration layer and use a dedicated document-processing component for extracting and rebuilding the DOCX.

The most important rule is:

Do not recreate the document from translated plain text. Open the original document, replace only the translatable text inside it, and save it as a new file.