Slice text by index

Slice text returns the substring between a Start index (inclusive) and an End index (exclusive). The whole input is sliced as one string by default. Toggle Per Line to slice each line on its own. Toggle Reverse to flip the resulting slice. Indexes are zero-based; characters before Start and at-or-after End are dropped.

Input
Line 1:1 LF cloud_done Saved locally
Result Slice Text
0 lines 0 chars

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

  1. 1Paste your text into the input panel on the left.
  2. 2Set Start to the zero-based index of the first character you want to keep.
  3. 3Set End to the zero-based index just past the last character you want to keep.
  4. 4Toggle Per Line on if you want the slice applied line-by-line.
  5. 5Toggle Reverse on if you want the slice flipped end-to-end.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun 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.

Input
The quick brown fox jumps over the lazy dog.
Output
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?
Yes. Start is the index of the first kept character; End is the index just past the last kept character. (0, 5) returns the first five characters.
What happens if End is past the end of the text?
The slice stops at the actual length of the source. No padding is added, no error is thrown.
Can I slice each line separately?
Yes. Turn Per Line on. The same Start / End window is applied to each line independently.
Why do my emoji break when I use Reverse?
Reversal is on UTF-16 code units, so astral characters (emoji, some CJK) made of surrogate pairs get split. If that matters, reverse with a grapheme-aware tool externally.
How is this different from extract line range?
Slice cuts by character index. Extract line range cuts by line number. Use slice for fixed-width record fields, line range for contiguous rows.