Py String To Dict
Type a Python Dict Literal, Get a Real Dict, Feed Pandas
- PYDICT
Need a Python dictionary in your workflow? Py String To Dict is the direct route: type a dict literal into a multiline text box, get a PYDICT out. It's the hand-typed counterpart to the Py Kv create nodes, and it's the one to use when you want several entries at once instead of building them one key at a time.
In practice this is a JSON-adjacent workhorse. Want to hand Pandas Create From Dict a small table in one shot? Type it here. Want a structured payload riding through the graph? Here.
How it works
The node parses your text with ast.literal_eval() - not eval(), which is an important distinction. literal_eval only accepts literal values (dicts, lists, strings, numbers, booleans, None), so it's safe to run on text that might come from somewhere untrusted. It won't execute code. But it's also strict: the input must be a valid Python dict literal.
Practically that means: {"name": "Alice", "score": 95, "tags": ["a", "b"]} works. And because it's Python, not JSON, true/false/null are invalid - you need True/False/None. Single quotes are fine, and keys don't need to be strings if you want {1: "one"}.
Inputs and outputs
data- the multiline string holding your dict literal.
Output: a single PYDICT - the parsed dictionary. Feed it to dict-consuming nodes like Pandas Create From Dict.
Install
Part of HowToSD/ComfyUI-Data-Analysis. Manager: search "Data analysis" in the Custom Node Manager, install, restart, reload the browser tab. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis # README: example workflows need this folder name
pip install -r requirements.txt
No models, no GPU.
Common issues
Syntax is the whole ballgame. A trailing comma inside the braces is fine; a missing closing brace or a true instead of True raises a parse error, loudly. People paste JSON and wonder why it fails - the true/null booleans are the usual culprit. Also, literal_eval doesn't allow arbitrary expressions or variables, so {"x": len("hi")} will error; keep it to literals. If you want to build a dict without typing a literal at all, the Py Kv create nodes are your widget-driven alternative.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| data | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| PYDICT | PYDICT | — |