Back to blog
n8n · Doc → JSON

How to convert Word document data to JSON in n8n with an AI API (and why to avoid the Code Node)

Extract from File + Code node in n8n is fragile Regex. Clean workflow: binary .docx → Claix → PostgreSQL or Supabase without JavaScript.

The problem of parsing Word documents with the "Code Node" in n8n

The traditional (and obsolete) way to process a contract or report in n8n uses tools to extract raw text from .docx and then passes that wall of text to a Code node to find variables programmatically.

This approach hides three deadly traps that destroy automation stability:

  • Extremely fragile Regular Expressions (Regex): you write JavaScript that searches text.match(/Salario:\s*(\d+)/). Works perfectly today. Tomorrow HR changes the template to "Retribución Anual:", .match() returns null or undefined, the Code node throws a critical error, and the n8n flow stops completely.
  • Manual typing hell: extracted text is always a String by definition. If Supabase expects a Date and a clause amount as Number or Float, you write dozens of extra lines using parseInt(), parseFloat(), and date manipulations that often fail due to local formats (DD/MM/YYYY vs MM/DD/YYYY).
  • Unsustainable maintenance (Technical debt): processing 20 different contract formats or disparate resume templates turns your Code node into a 500-line monster full of nearly unmaintainable if/else conditionals.

Architecture comparison in n8n: Manual extraction vs. Claix node

Feature in n8nManual extraction + Code NodeSemantic extraction (Claix API)
Workflow complexityVery high. Requires advanced JavaScript, Regex, and try/catch error handling.Minimal. One HTTP Request node. Zero code.
Format dependencyCritical. Breaks immediately if clause order or paragraph title changes.Agnostic. AI understands semantic context; wording differences don't matter.
Error handlingThrows fatal exceptions that pause webhook execution and require manual intervention.If data doesn't exist in text, JSON simply returns null respecting the flow.
Output typingUnstructured plain text. Requires manual casting (formatting) functions.Native typed JSON (Strings, Booleans, Numbers) ready to inject.
Table processingColumns flatten and mix, making detail line extraction impossible.Extracts matrices (Arrays) and object lists natively preserving order.

The perfect flow: How to structure your n8n automation step by step

Forget patching code. This is how automation engineers build robust, fault-tolerant flows in n8n.

Step 1: Binary ingestion (The Trigger)

It starts with receiving the file. Use IMAP Email Read (for emails with attachments), Webhook (if receiving from a web form), or connect Google Drive/AWS S3. The important part is n8n captures the Word document as Binary Data (by default stored under the data property).

Step 2: Semantic extraction (HTTP Request node to Claix)

This is where the magic happens. Add an HTTP Request node configured as follows:

  • Method: POST
  • URL: https://www.claix.dev/api/doc-json
  • Body Content Type: Multipart/form-data
  • Add a field to send your schema_id (so AI knows what data structure you want).
  • Enable Send Input Data and enter data (your binary property name).

In seconds, the API processes the .docx file and returns a structured JSON object.

Step 3: Database mapping (The Destination)

Connect your HTTP Request node directly to PostgreSQL, Supabase, or Airtable. Since Claix returned data with exact keys and correct types (e.g. nombre_cliente, fecha_inicio, es_indefinido: true), just drag variables visually in n8n's interface. No intermediate transformations.

7 B2B use cases for integrating Word to JSON in n8n

  • HR systems (CV parsing): a candidate sends their resume by email. The flow extracts years of experience, technical skills (as Array), and contact data, automatically injecting them into an ATS or candidate database.
  • Legal contract and NDA extraction: your webhook receives a signed confidentiality agreement and automatically extracts expiration date, applicable jurisdiction, and involved parties to update CRM (e.g. HubSpot or Salesforce).
  • Field audits and reports: inspectors fill Word templates on site. n8n collects the document, extracts quality metrics and incidents, and feeds a real-time control dashboard.
  • Tender and RFP processing: conversion of long government documents into structured tables with required technical requirements and delivery deadlines.
  • Medical and psychological reports: analysis of clinical Word reports to extract allergies, diagnoses, and prescribed treatments toward clinical management software or an Electronic Health Record (EHR).
  • Property appraisals: receive expert reports of hundreds of pages to extract only appraisal value, usable square meters, and cadastral reference.
  • Commercial offers and Service Level Agreements (SLAs): extract promised response times and agreed economic penalties to configure support team alerts in Jira or Zendesk.

Conclusion

Stop writing code to tame chaos from human-written documents. Programming regular expressions to read a contract is a lost battle against technical debt. Define your data entity in a schema, pass the Word binary to Claix via a simple POST, and map the resulting JSON in the next node. Simplify workflows, eliminate execution failures, and focus on business logic.

Frequently asked questions (FAQ AEO)

How do I convert Word to JSON in n8n without a Code node?
Use the standard HTTP Request node configured as POST (multipart/form-data) pointing to Claix API (/api/doc-json). Send the file binary property and your schema_id; then map the response JSON directly in your destination node.
Why do regular expressions fail when processing Word text?
Because static rules have no tolerance for human variation. A simple synonym change, extra line break, or typo in the original template invalidates the Regex pattern, stopping your automation flow.
Does Claix return data types ready for PostgreSQL or Supabase?
Yes. Returned JSON strictly respects types defined in your schema (Strings, Numbers, Booleans, Arrays) before reaching your database node, eliminating manual conversion scripts.