Text: Truncate
Cap a string to a maximum number of characters, appending an ellipsis when the input is too long. Counts characters, not bytes — safe for multi-byte UTF-8.
Example
Max length: 10, Ellipsis: "..."
Input: "hello world" → Output: "hello w..."
Input: "hi" → Output: "hi"
Parameters
Max length
Hard cap on the output's character count, ellipsis included. Strings at or
below this length pass through unchanged. Defaults to 0.
Ellipsis
Suffix appended when the input was actually truncated. Defaults to ....
If the ellipsis is longer than Max length, the output is just the
ellipsis.
Input
Stringrequired
Text to truncate.
Output
String
The truncated text.