Get Substring JNK
Slice long names down to filename-friendly size
- text
Get Substring is a small text-slicing tool with one very specific, very practical use case: trimming long model names down to something you can put in a filename. The pack's own README says it outright - it's for "trimming long model names when saving results." Model names like dreamshaper_8_sdxl_fp16_ema_no_watermark.safetensors don't make great filenames, and if you're auto-saving renders with the model name embedded (the whole point of the "with Name" nodes), you'll want to cut the tail off.
It does one job with four inputs, and it does it without surprises. text is whatever string you feed it - typically the name output of Load Checkpoint Model with Name or Load LoRA with Name. start is where to begin, length is how many characters to take, and the from_end toggle flips the anchor so start counts backward from the end of the string instead of the front.
The one input that changes the math
from_end- when off (default), it's plain slicing:text[start : start+length]. When on, the start position is recomputed aslen(text) - start - length, which is the trick that lets you grab a fixed-length window near the end of a string without knowing its total length. Handy for stripping a known suffix pattern.
Output: text - the slice, as a STRING.
Installing it
Pack install: search JNK in ComfyUI Manager, or
cd ComfyUI/custom_nodes/
git clone https://github.com/Aljnk/ComfyUI-JNK-Tiny-Nodes.git
Pure Python string ops, no dependencies beyond core.
Where people get burned
The slicing is forgiving in a way that can mask mistakes: Python returns whatever's in range and silently truncates, so asking for a slice past the end of the string gives you a shorter result instead of an error. That's convenient until you're trimming names and a length that's too big eats into the part you wanted to keep. The from_end mode also expects length to make sense - a length larger than the string will push the computed start negative, and you get Python's quirky negative-index behavior rather than a clear failure. When the output looks wrong, the fix is almost always "your start/length don't add up," not a broken node. Test with a couple of values before wiring it into your save pipeline, and it'll behave exactly like the text editor you wish you had in the graph.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | β | |
| start | INT | 00β999999 | β |
| length | INT | 11β999999 | β |
| from_end | BOOLEAN | false | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | β |