SplitString icon

SplitString

Splits a string based on a separator in his parts

Overview

This node splits a given string into multiple parts based on a specified separator. It is useful when you need to break down a single string input into smaller components for further processing or analysis within an n8n workflow. For example, splitting a file path like folder/subfolder/file.txt into its individual segments or parsing CSV-like strings.

The node supports mapping each split part to custom field names and optionally includes additional fields from the original input in the output.

Properties

Name Meaning
Value to Split The string value that will be split into parts. Example: "hello/world"
Separator The character(s) used to split the string. Default is /. Example: /
Options Collection of optional settings:
  Mapping Define how each split part maps to a named field with a specific index. Example: name=fieldName, index=0
  Input Fields to Include Comma-separated list of additional input fields to include in each output item. Example: field1,field2

Output

The output is an array of items where each item contains a JSON object:

  • If mappings are defined, each split part is assigned to the corresponding field name as per the mapping.
  • If no mappings are provided, each split part is output under the field item.
  • Additionally, any specified input fields are included in each output item unchanged.

Example output JSON structure with mappings:

{
  "json": {
    "fieldName1": "part0",
    "fieldName2": "part1",
    "field1": "valueFromInput",
    "field2": "valueFromInput"
  }
}

Example output JSON structure without mappings:

{
  "json": {
    "item": "splitPart",
    "field1": "valueFromInput"
  }
}

No binary data output is produced by this node.

Dependencies

  • No external services or API keys are required.
  • The node operates purely on the input data and parameters configured within n8n.

Troubleshooting

  • Empty or missing input string: If the "Value to Split" is empty or not provided, the output will be empty or may not behave as expected. Ensure the input string is correctly set.
  • Incorrect separator: Using a separator that does not exist in the input string will result in a single-item output containing the entire string.
  • Invalid mapping indices: Mapping indices should be valid numbers within the range of split parts. Out-of-range indices will result in missing fields in the output.
  • Input fields not found: Specified input fields to include must exist in the incoming data; otherwise, they will be omitted silently.

Links and References

Discussion