Overview
The "Text Replacer" node processes input text by replacing multiple user-defined placeholders with specified replacement values. It is useful in scenarios where dynamic text generation or templating is needed, such as customizing email templates, generating personalized messages, or preparing documents with variable content.
For example, if you have an input text like "Hello $$name$$, your order $$orderId$$ is confirmed," and provide replacements for $$name$$ and $$orderId$$, the node will output the text with those placeholders replaced by actual values.
Properties
| Name | Meaning |
|---|---|
| Input Text | The source text containing placeholders to be replaced. |
| Output Key Name | The key name in the output JSON where the processed text (with replacements applied) will be stored. Default is "processedText". |
| Replacements | A collection of placeholder/replacer pairs. Each pair defines: - Placeholder: The exact text to find in the input (e.g., $$nombre$$). - Replacer: The value that will replace the placeholder in the text. |
Output
The node outputs an array of items, each containing a JSON object. For each input item, the output JSON includes all original fields plus a new field named according to the "Output Key Name" property. This field contains the input text after all specified placeholders have been replaced with their corresponding replacers.
If no replacements are provided or no input text exists, the output will either contain the original text unchanged or simply pass through the original data.
No binary data is produced by this node.
Example output JSON structure:
{
"originalField1": "value1",
"processedText": "Hello John, your order 12345 is confirmed"
}
Dependencies
- No external services or API keys are required.
- The node runs entirely within n8n and depends only on standard JavaScript functionality.
Troubleshooting
Warning: No input text for item X
Occurs when the input text property is empty or missing for a given item. Ensure the "Input Text" property is correctly set and not empty.Warning: No replacements for item X
Happens if no placeholder-replacer pairs are provided. Add at least one replacement group to perform substitutions.Warning: Placeholder "..." not found
Indicates that a specified placeholder does not exist in the input text. Verify that placeholders exactly match the text in the input, including any special characters.If an error occurs during processing and "Continue On Fail" is enabled, the node will add an error message to the output JSON under the
errorkey instead of stopping execution.