_.escape
Make user text safe for HTML
- obj
- *
_.escape takes a string and HTML-escapes it: &, <, >, " and ' become their entity forms so the text renders as literal characters instead of being interpreted as markup. The author's description is one line: "Escape a string for HTML interpolation."
In a Comfy workflow that's a narrow but real job: if you're building HTML to feed a text-overlay node, an HTML preview, or any tool that renders markup, and some of your content comes from prompts, filenames, or user input, then a stray < or & can break the render. Run it through _.escape first and the text stays text.
How it works
Generated wrapper around underscore3, the bundled Python port of Underscore.js. The escape map follows Underscore's standard set:
&→&<→<>→>"→"'→'(Underscore uses the numeric/hex form for the apostrophe)
The _.unescape sibling reverses it. Note the input here is typed as obj (any) - the wrapper's generic primary input - so you'll feed it a STRING from any text-producing node.
Inputs and output
obj(any type) - the string to escape. Accepts a_.CHAINto continue a chain.- Output:
*(any type) - the escaped string.
No widgets.
Installing it
Part of sfinktah/comfy-ovum ("comfy-ovum"):
- ComfyUI Manager: search "comfy-ovum", install, restart.
- Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/sfinktah/comfy-ovum, restart.
No model downloads; light dependencies; underscore3 bundled in the repo.
Should you bother?
Honestly, _.escape is a niche node - you only need it if something downstream actually renders HTML. If nothing in your graph interprets markup, escaping does nothing but make the text uglier, so don't add it "just in case." Where it earns its keep is a caption or overlay pipeline where prompt text (which can legally contain <, >, &) gets interpolated into an HTML template. Escape the user-controlled parts, not the template you wrote. And as with the rest of this family, remember the author flags the underscore suite as work-in-progress in the README - for a utility this small that's mostly theoretical, but test with a string full of &<>"' once before you trust it.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| objopt | * | Primary input object. Also accepts _.CHAIN to continue chaining. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |