Built-in Data Type Conversion Example
Demonstrate how to convert between various built-in data types within a workflow. Input any data value and output its converted form.
Download WorkflowTry in Cloud API documentation
About
Demonstrate how to convert between various built-in data types within a workflow. Input any data value and output its converted form.
What you provide
- Reading the workflow
Runs in ComfyUI. This workflow can't run on this page. Download it and open it in ComfyUI.
Download WorkflowNo sample outputs for this workflow yet.
Inside the workflow
A read-only preview of the node graph. Open it in Comfy Cloud or download it to edit the nodes.
Loading the graph
Open full-size workflow preview- Comfy Cloud
- Yes
- Author
- Author unavailable
Requires custom nodes
- Reading the workflow
Use this workflow from code
Generated from the workflow graph and inputs when possible; stored examples are shown otherwise. Review credentials and endpoints before running code, which may incur charges.
1 Get API key ↗
What you need
- Runs on
- Comfy Cloud
- Key
- COMFY_API_KEY
Needs a paid Cloud plan and credits.
Download API JSONAPI documentation ↗
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"2": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "1"
},
"_meta": {
"title": "Text (Multiline)"
}
},
"3": {
"class_type": "ComfyNumberConvert",
"inputs": {
"value": [
"2",
0
]
},
"_meta": {
"title": "Convert Number"
}
},
"5": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"3",
0
]
},
"_meta": {
"title": "Preview as Text (Float)"
}
},
"6": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"3",
1
]
},
"_meta": {
"title": "Preview as Text (Int)"
}
},
"8": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 0
},
"_meta": {
"title": "Int"
}
},
"9": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"8",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"10": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 1.5
},
"_meta": {
"title": "Float"
}
},
"11": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"10",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"12": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"9",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"13": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"11",
0
]
},
"_meta": {
"title": "Preview as Text (String)"
}
},
"14": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a",
"values.a": [
"8",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"15": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"14",
2
]
},
"_meta": {
"title": "Preview as Text"
}
},
"16": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"14",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"17": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"14",
1
]
},
"_meta": {
"title": "Preview as Text"
}
},
"18": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a",
"values.a": [
"10",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"20": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"18",
0
]
},
"_meta": {
"title": "Preview as Text (Float)"
}
},
"21": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"18",
1
]
},
"_meta": {
"title": "Preview as Text (Int)"
}
},
"22": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"18",
2
]
},
"_meta": {
"title": "Preview as Text (Boolean)"
}
},
"23": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a",
"values.a": [
"3",
1
]
},
"_meta": {
"title": "Math Expression"
}
},
"24": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"23",
2
]
},
"_meta": {
"title": "Preview as Text (Boolean)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)