---
related_nodes: ["loop", "discord_action"]
---

# Split Text

Divides one text input into an ordered array of bounded, non-empty text chunks. It is a reusable transform; it has no provider-specific behavior.

## Configuration

- `mode`
  - `line` (default): preserves source order and packs complete newline-terminated lines together while they fit. A line longer than the limit is split at a fitting whitespace boundary when possible, otherwise at a Unicode-scalar boundary.
  - `character`: splits at the largest Unicode-scalar boundary that fits the limit.
- `max_chars`: maximum UTF-16 code units in each chunk. Defaults to `1850`, a conservative margin below Discord's 2,000-unit message-content limit. Must be at least `1`.

The node never truncates, removes, or reorders input text. It does not split a Unicode scalar value. If `max_chars` is too small for one scalar (for example, an emoji with `max_chars = 1`), it fails instead of emitting malformed text.

## Inputs and Output

- `input`: one text value. Objects, arrays, and other JSON values fail rather than being stringified.
- `output`: one ordered array of text chunks. An empty input produces `[]`.

The array is one workflow value, not an item stream. It does not invoke downstream nodes once per chunk by itself.

## Discord Message Pattern

Use this for unbounded text sent through a Discord operation that **creates a message** (`send_message` or `reply`):

```text
Upstream text → Split Text.input
Split Text.output → Loop.input
Loop.loop → Discord Action.input
```

Configure the Discord Action body with `content: {{ input }}`. `Loop.loop` runs each chunk sequentially, preserving order, and Discord Action sends one message per iteration.

Do not loop `edit_message`, `edit_original_response`, `update_message`, or an initial `respond_to_interaction`: each is limited to one 2,000-unit message, and repeated iterations overwrite the same message or fail after the initial response. Shorten the content, attach a file when the operation supports attachments, or use a deferred/follow-up workflow appropriate to the interaction.
