Skip to main content

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​

InputTypeDescriptionDefault
TextTextThe input text string to be trimmed.-

Outputs​

OutputTypeDescription
OutputTextThe trimmed text string with whitespace removed according to the selected mode.

Properties​

PropertyTypeDescriptionDefault
Trim SidesEnumDetermines 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 trimSides property is specified, the node defaults to trimBoth, 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(), and trimEnd() 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:

  1. Connect a Form Data node (capturing a text field) to the Text input
  2. Set Trim Sides to trimBoth to ensure no accidental spaces are stored
  3. 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".