Substring with optional per-line and reverse
The slice is implemented with String.prototype.substring(start, end). Start is inclusive (the first kept character), End is exclusive (the first dropped character). If End is past the length of the source the slice stops at the actual length without erroring. Both indices are clamped to non-negative values via the registry (min: 0).
Per Line off (the default) slices the whole input as one string. Turn it on and the same Start / End pair is applied to each line independently after splitting on \r?\n. Useful for cropping fixed-width records.
Reverse takes the slice result, splits it into characters, and reverses them. With per-line on, each line is reversed individually after slicing. To reverse without slicing first use reverse text. To pick a contiguous range of whole lines instead of characters, use extract line range.
How to use slice text by index
- 1Paste your text into the input panel on the left.
- 2Set Start to the zero-based index of the first character you want to keep.
- 3Set End to the zero-based index just past the last character you want to keep.
- 4Toggle Per Line on if you want the slice applied line-by-line.
- 5Toggle Reverse on if you want the slice flipped end-to-end.
Keyboard shortcuts
Drive TextResult without touching the mouse.
| Shortcut | Action |
|---|---|
| Ctrl F | Open the find & replace panel inside the input Plus |
| Ctrl Z | Undo the last input change |
| Ctrl Shift Z | Redo |
| Ctrl Shift Enter | Toggle fullscreen focus on the editor Plus |
| Esc | Close find & replace, or exit fullscreen |
| Ctrl K | Open the command palette to jump to any tool Plus |
| Ctrl S | Save current workflow draft Plus |
| Ctrl P | Run a saved workflow Plus |
What this tool actually does
Zero-based, half-open interval
Indices follow JavaScript conventions: Start is inclusive, End is exclusive. Start = 0, End = 5 on ABCDEFGHIJ returns ABCDE.
End beyond the length stops at the length
If End is larger than the source length the slice stops at the source's actual length. No padding is inserted, no error is thrown.
Per Line applies the same window to each line
With the toggle on the input is split on \r?\n, each line is sliced with the same Start / End, and the result is rejoined with \n. Lines shorter than Start become empty.
Reverse flips the slice character by character
The slice result is split into characters with split(''), reversed, and joined back. With per-line on, each line's slice is reversed on its own. Note that surrogate pairs (emoji, some CJK) split into two halves under this method.
Runs entirely in your browser
One substring call per slice (plus the optional reverse). No upload, no server-side processing.
Worked example
Start 4, End 15, Per Line off, Reverse off. The slice [4, 15) picks quick brown out of the sentence.
The quick brown fox jumps over the lazy dog.
quick brown
Settings reference
| Behaviour | Effect on output |
|---|---|
| Start (zero-based, inclusive) | First character kept. 0 means the very start. |
| End (zero-based, exclusive) | First character dropped. Beyond the length stops at the length. |
| End ≤ Start | Returns an empty string (or empty lines in per-line mode). |
| Per Line off | Slice is applied to the whole input as one string. |
| Per Line on | Slice is applied to each line independently after splitting on \r?\n. |
| Reverse off | Slice is returned as-is. |
| Reverse on | Slice is flipped character by character. Per-line mode reverses each line's slice. |
| Surrogate pairs | Reverse may split astral characters (emoji, some CJK) because reversal is on UTF-16 code units, not graphemes. |
FAQ
Are the indices zero-based?
(0, 5) returns the first five characters.