Nodes/Plush-for-ComfyUI/Plush - Type Converter🧸
ComfyUI Node

Plush - Type Converter🧸

Turn a string into every type at once

By glibsonoran·Created 3 years ago·Updated about a year ago· 197
Plush - Type Converter🧸
    • Text
    • Float
    • Integer
    • Boolean
    • List
    • JSON/Dict
    • help
    • Troubleshooting
    Text
    Cross_reference_typestrue

    Type Converter takes a string and parses it into a bunch of different data types, each on its own output. Feed it text and it hands you back a Float output, an Integer output, a Boolean output, a List output, a JSON/Dict output - plus the original Text. You wire out whichever one the downstream node actually wants. It's the little adapter you drop in when a value arrives as text but the node consuming it expects, say, an actual number or a parsed dict.

    This matters more than it sounds like, because a lot of ComfyUI plumbing is string-typed by default. Text fields, LLM output, values you typed by hand - they're strings. But plenty of nodes want a real INT, a FLOAT, or structured data. Rather than hunting for a separate "string to int" node and a separate "string to float" node, Type Converter does the whole spread in one shot and lets you pick. It's especially natural next to the rest of this pack: Plush's Advanced Prompt Enhancer can be pushed to emit JSON, and there's an Extract JSON data node for querying it - Type Converter is the general-purpose sibling that turns a raw string into a usable typed value.

    It's one of glibsonoran's Plush/Utils helpers, added in the October 2024 utility batch. Like the rest of them it needs no API key and no model - the pack's marquee nodes are the LLM prompt writers, but this one is pure local parsing.

    How it works

    You give it a string; it attempts to interpret that string as each of the supported types and exposes every interpretation as a separate output at once. "3.14" becomes a usable Float, "true" becomes a Boolean, a bracketed sequence becomes a List, a {...} blob becomes a JSON/Dict. You don't choose a target type up front - you just take the output you need off the node.

    The one real toggle is Cross_reference_types. With it on (the default), the node cross-references equivalent representations of a value across types rather than treating each output in strict isolation - so, for instance, a numeric string resolves sensibly across the Float and Integer outputs. Leave it on unless you have a specific reason not to; it's the more forgiving behavior.

    Inputs and outputs

    From the node's schema:

    • Text - a multiline string input. The value to parse.
    • Cross_reference_types - a boolean (default true). Cross-references equivalent data types, as above.

    And the outputs, one per target type plus two diagnostics:

    • Text, Float, Integer, Boolean, List, JSON/Dict - the converted value in each form; take whichever fits the downstream input.
    • help - wire a text-display node here and queue to read a built-in explanation of the fields. Standard Plush convenience.
    • Troubleshooting - Plush's per-node log output. Hook up a text display and it shows the INFO/WARNING/ERROR captured during the run - this is where a failed parse tells you what went wrong.

    Installing it

    ComfyUI Manager: Install Custom Nodes, search Plush, choose Plush-for-ComfyUI, install, restart. Manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/glibsonoran/Plush-for-ComfyUI.git
    cd Plush-for-ComfyUI
    python -m pip install -r requirements.txt
    

    Restart ComfyUI. The requirements.txt install pulls the OpenAI library the pack's LLM nodes use; Type Converter doesn't need it, but the install runs pack-wide, so let it finish. No model downloads.

    Common issues

    The obvious one: the string has to actually be the type you're pulling. Take the Integer output from "hello" and there's nothing sane to hand you - a value that can't be parsed to the type you grabbed will fail or come back unusable. When something's off, that's exactly what the Troubleshooting output is for; connect a text-display node to it and read what the parser complained about instead of guessing. The JSON/Dict output is the pickiest - it wants genuinely valid JSON, so a near-miss with single quotes or a trailing comma won't parse.

    Also don't confuse it with Text (Any) from the same pack. Text (Any) uses a wildcard output to bypass the editor's type check without changing the value; Type Converter actually parses and produces a real typed value. When a node needs a true number or dict rather than a string wearing a wildcard hat, this is the one you want. And if the pack won't load, check the ComfyUI console for a failed OpenAI dependency install - that's the usual Plush install snag, not anything about this node.

    CategoryPlush🧸/Utils

    Inputs (2)

    NameTypeDefaultDescription
    TextoptSTRING
    Cross_reference_typesoptBOOLEANtrue

    Outputs (8)

    NameTypeDescription
    Text*
    Float*
    Integer*
    Boolean*
    List*
    JSON/Dict*
    helpSTRING
    TroubleshootingSTRING