Replace Text in Word Document using n8n action
PDF4me Replace Text in Word Document enables finding and replacing text in Word documents through n8n automation workflows with advanced formatting options and comprehensive text styling capabilities. This powerful text replacement feature supports multiple replacement phrases, case-sensitive matching, whole word matching, regular expressions, and detailed formatting control with full control over font properties, colors, text effects, and positioning, perfect for document automation, template processing, and content management workflows.
Setup
Add the PDF4me "Replace Text in Word Document" node to your n8n workflow and configure the required parameters. For initial setup instructions, see our n8n Integration Guide.
Prerequisites:
- PDF4me API credentials
- n8n workflow access
Configuration:
- Add PDF4me node to workflow
- Select "Replace Text in Word Document" action
- Configure input parameters (see below)

Parameters
Complete list of parameters for the Replace Text in Word Document action. Configure these parameters to control text replacement behavior.
Important: Parameters marked with an asterisk (***) are required. The Text Replacements array must contain at least one replacement phrase.
| Parameter | Type | Description | Example |
|---|---|---|---|
| Input Data Type*** | String | Word Document Input Format Selection • Choose the format of your Word document data input • PDF4me supports multiple input types • Options: Binary Data, Base64 String, or URL | Binary Data |
| Input Binary Field*** | Binary | Binary Word File Input (Required if Binary Data) • Reference Word file (.docx, .doc) from previous n8n node or file upload • PDF4me processes binary Word files with automatic format detection • Required when Input Data Type is "Binary Data" | {{ $binary.data }} |
| Base64 Word Content*** | String | Base64 Encoded Word Input (Required if Base64 String) • Provide Word content (.docx, .doc) as base64 encoded string for secure transmission • PDF4me automatically decodes and processes the Word content • Required when Input Data Type is "Base64 String" | UEsDBBQABgAI... |
| Word Document URL*** | String | Public Word Document URL Input (Required if URL) • Provide a public/open permission URL to the Word file (.docx, .doc) to be processed • PDF4me downloads and processes the Word file from the provided URL • Required when Input Data Type is "URL" | https://abc.com/document.docx |
| Word Document Name*** | String | Word Document Input Filename • Specify the name of the input Word file with proper extension (.docx, .doc) • PDF4me uses this for format detection and processing optimization | document.docx |
| Text Replacements*** | Array | Array of Text Replacement Objects • Array of text replacement objects, must contain at least one replacement phrase • Each replacement object contains: Search Text (required), Replacement Text (optional), Match Case, Match Whole Word, Use Regular Expressions, and font formatting options | [{"SearchText": "old text", "ReplacementText": "new text"}] |
Text Replacement Object Properties:
| Property | Type | Description | Example |
|---|---|---|---|
| SearchText*** | String | Text to search for - Text string to search for in the document. Cannot be null or empty | "old text" |
| ReplacementText | String | Text to replace with - Text to replace the found text with. Can be empty string to remove found text | "new text" |
| MatchCase | Boolean | Case-sensitive matching - True for case-sensitive search, False for case-insensitive (default: false) | false |
| MatchWholeWord | Boolean | Whole word matching - True to match only complete words, False for partial matches (default: false) | false |
| UseRegularExpressions | Boolean | Regular expression support - True to treat SearchText as regex pattern, False for literal text (default: false) | false |
| FontName | String | Font family - Font family to apply to replacement text (e.g., "Arial", "Times New Roman") | "Arial" |
| FontColor | String | Text color - Named colors, hex format, or RGB format (e.g., "Red", "#FF0000", "RGB(255,0,0)") | "Red" |
| FontSize | Number | Font size in points - Font size for replacement text (e.g., 10, 12, 14, 16) | 14 |
| BackgroundColor | String | Background color - Background color for replacement text (e.g., "Yellow", "#FFFF00") | "Yellow" |
| Bold | Boolean | Apply bold formatting - True to apply bold, False for no bold (default: false) | false |
| Italic | Boolean | Apply italic formatting - True to apply italic, False for no italic (default: false) | false |
| Underline | Boolean | Apply underline formatting - True to apply underline, False for no underline (default: false) | false |
| Strikethrough | Boolean | Apply strikethrough - True to apply single strikethrough, False for no strikethrough (default: false) | false |
| DoubleStrikethrough | Boolean | Apply double strikethrough - True to apply double strikethrough, False for no double strikethrough (default: false) | false |
| Subscript | Boolean | Apply subscript formatting - True to apply subscript, False for no subscript (default: false) | false |
| Superscript | Boolean | Apply superscript formatting - True to apply superscript, False for no superscript (default: false) | false |
| WordSpacing | Number | Word spacing in points - Spacing between words (default: 0) | 0 |
Output
Output Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| fileName | String | Word document filename with text replaced - The name of the output Word document file after text replacement | document_text_replaced.docx |
| fileSize | Number | File size in bytes - The size of the Word document in bytes after text replacement | 13370 |
| success | Boolean | PDF4me operation status - Boolean flag indicating the success or failure of the text replacement operation. PDF4me returns true for successful operations and false for any errors | true |
| originalFileName | String | Original Word document filename - The name of the input Word document file | document.docx |
| phrasesCount | Number | Number of replacement phrases - The total count of text replacement phrases that were processed | 1 |
| cultureName | String | Culture/Locale code - Culture code used for document processing (e.g., "en-US", "de-DE", "fr-FR") | en-US |
| message | String | Operation message - Descriptive message indicating the result of the text replacement operation | Text replaced successfully |
N8N Action Response
The PDF4me Replace Text in Word Document API returns a response that can be viewed in multiple formats. Choose the view that best fits your needs:
- JSON
- Table
- Schema
- Binary
JSON Response Format
The raw JSON response from the API:
[
{
"fileName": "document_text_replaced.docx",
"fileSize": 13370,
"success": true,
"originalFileName": "document.docx",
"phrasesCount": 1,
"cultureName": "en-US",
"message": "Text replaced successfully"
}
]
Table View
Response data in a structured table format:
| Parameter | Value |
|---|---|
| fileName | document_text_replaced.docx |
| fileSize | 13370 |
| success | true |
| originalFileName | document.docx |
| phrasesCount | 1 |
| cultureName | en-US |
| message | Text replaced successfully |
Schema View
The data structure and types of the response:
1 item
fileName: T document_text_replaced.docx
fileSize: # 13370
success: ☑ true
originalFileName: T document.docx
phrasesCount: # 1
cultureName: T en-US
message: T Text replaced successfully
Type Indicators:
T= String (Text)#= Number☑= Boolean[]= Array
Binary Data View
The actual Word document file data and metadata:
data
─────────────────────────────
File Name: document_text_replaced.docx
File Extension: docx
Mime Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
File Size: 13.4 kB
Binary Data Access:
- n8n Binary Object:
$binary.data.data - Base64 Content: Available for direct use
- File Operations: Ready for download, email, or storage
Use Cases
Enterprise Document Automation
- Document Automation: Replace placeholder text with dynamic content
- Template Processing: Update template variables with actual values
- Content Management: Standardize terminology and formatting
- Document Personalization: Insert personalized information into documents
AI-Powered Document Processing
- Multi-Format Support: Process Word documents in .docx and .doc formats
- Multi-Language Processing: Extract data from documents in various languages
- Intelligent Field Recognition: Automatically identify and replace text patterns
Business Intelligence and Analytics
- Content Standardization: Ensure consistent terminology across documents
- Compliance Monitoring: Update documents to meet regulatory requirements
- Performance Metrics: Track processing accuracy and efficiency