String node

String Part

Extract a substring from a string starting at a given index for a specified length. The extraction is boundary-safe, automatically clamping to valid ranges so it never produces an error on out-of-bounds values.

Inputs

PortTypeDefault
TextThe source text to cut a piece out of. Empty text always returns an empty part.string—
IndexWhere the cut starts, counting from 0 for the first character. Negative values or anything past the end of the text return nothing rather than wrapping.int0
LengthHow many characters to take. Must be at least 1 — zero or negative returns nothing, and asking for more than remains simply runs to the end of the text.int1

Outputs

PortType
String Partstring
Total Lengthint

Screenshots

String Part Node
String Part Node

How It Works

String Part extracts a portion of the input string beginning at the specified Index and continuing for the specified Length. Character positions are zero-based: the first character is at index 0, the second at index 1, and so on.

The extraction is boundary-safe:

  • If the Index exceeds the string length, the output is an empty string.
  • If the Index plus Length extends beyond the end of the string, the output is truncated to include only the available characters.
  • Negative Index values are clamped to 0.

The Total Length output always reports the full character count of the original input string, regardless of the extraction parameters.

Examples

TextIndexLengthString PartTotal Length
"Grafit"03"Gra"6
"Grafit"33"fit"6
"Grafit"410"it"6
"Grafit"101""6
"Hello"01"H"5

Use Cases

  • Extract fixed-width fields from formatted strings such as serial protocol data.
  • Get the first N characters for preview or truncation purposes.
  • Isolate substrings at known positions in structured text data.
  • Build a sliding window by animating the Index input to scan across a string over time.

Tips

  • The Total Length output is useful for calculating the Index needed to extract the last N characters: set Index to (Total Length - N).
  • For splitting a string at a delimiter rather than a fixed position, use String Splitter instead.
  • Combine with String Length and Math nodes to compute dynamic Index and Length values based on the input.
  • The boundary-safe behavior means you can safely use animated or data-driven Index values without worrying about crashes.

A ready-made example project for this node is built into Grafit Pro: select the node in the library and open or drag the example from its description panel.

Open String Part in the interactive catalog →

String Part is one of 381 nodes in Grafit Pro.

Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.

More String nodes