Data Converter
Actions49
- Base64 Actions
- Binary Actions
- Encoding Actions
- Format Actions
- HTML Actions
- String Actions
Overview
The node performs various string transformations and data conversions. Specifically, for the String resource with the Truncate operation, it truncates a given text input to a specified maximum length and appends an optional suffix (like "...") if the text exceeds that length.
This is useful in scenarios where you want to limit the length of text fields, such as shortening descriptions, titles, filenames, or any textual content to fit UI constraints or storage limits.
Example use cases:
- Truncating long product descriptions before displaying them on a website.
- Shortening user comments or messages to a fixed character count.
- Limiting filename lengths while preserving readability.
Properties
| Name | Meaning |
|---|---|
| Input Data | The text string to be truncated. |
| Length | Maximum number of characters to keep in the truncated string (default 100). |
| Suffix | Text to append at the end when truncation occurs (default "..."). |
Note: The Length and Suffix properties are part of the options for the truncate operation within the "Apply Multiple Operations" collection or directly used by the truncate operation.
Output
The output JSON contains a field named result which holds the truncated string.
Example output JSON:
{
"result": "This is a truncated text..."
}
No binary data output is produced by this operation.
Dependencies
- No external services or API keys are required.
- The node relies on internal utility functions for string manipulation.
- No special environment variables or n8n configurations are needed.
Troubleshooting
Common issues:
- Providing non-string input may cause unexpected results or errors.
- Setting the
Lengthproperty to zero or a negative number might produce empty or invalid output.
Error messages:
- If the input data is missing or not a string, the node may throw an error indicating invalid input.
- If the node is configured incorrectly (e.g., missing required parameters), it will throw a descriptive error.
Resolution tips:
- Ensure the "Input Data" property is set and contains valid text.
- Verify the
Lengthparameter is a positive integer. - Use expressions carefully to provide string inputs.
Links and References
- n8n Documentation
- General info on string truncation: https://en.wikipedia.org/wiki/String_truncation
- JavaScript String.prototype.slice() method (commonly used for truncation): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice