Trim Text
Uncontrolled node
Overview
The Trim Text node removes whitespace characters (spaces, tabs, newlines, etc.) from the beginning and/or end of a text string. This is useful for cleaning up user input, removing accidental leading/trailing spaces from data, or standardizing text formatting before further processing.
The node supports three trimming modes:
- Trim Both: Removes whitespace from both the start and end of the text (default)
- Trim Start: Removes whitespace only from the beginning of the text
- Trim End: Removes whitespace only from the end of the text
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| Text | Text | The input text string to be trimmed. | - |
Outputs
| Output | Type | Description |
|---|---|---|
| Output | Text | The trimmed text string with whitespace removed according to the selected mode. |
Properties
| Property | Type | Description | Default |
|---|---|---|---|
| Trim Sides | Enum | Determines which side(s) of the text to trim whitespace from. Options: trimBoth, trimStart, trimEnd. | trimBoth |
Runtime Behavior and Defaults
The Trim Text node is an uncontrolled data node, meaning it executes immediately when its input changes and does not require an event trigger to run.
- Default Behavior: If no
trimSidesproperty is specified, the node defaults totrimBoth, removing whitespace from both ends of the input text. - Non-string Input: If the input is not a string, the node returns an empty string.
- Whitespace Definition: The node uses JavaScript's standard
trim(),trimStart(), andtrimEnd()methods, which remove all whitespace characters including spaces, tabs, newlines, and other Unicode whitespace characters.
Example
Basic Usage
Connect a text source (such as a Plain Text node or form input) to the Text input. The node will automatically output the cleaned text.
Input: " Hello World "
Property: trimBoth (default)
Output: "Hello World"
Input: " Hello World "
Property: trimStart
Output: "Hello World "
Input: " Hello World "
Property: trimEnd
Output: " Hello World"
Cleaning Form Input
Use Trim Text to clean up user input before validation or database insertion:
- Connect a Form Data node (capturing a text field) to the Text input
- Set Trim Sides to
trimBothto ensure no accidental spaces are stored - Connect the Output to a Set Variable or database insertion node
This ensures that entries like " user@example.com " are stored as "user@example.com".