Pandas Save JSON
Pandas Save JSON
- dataframe
- STRING
CSV is for humans and spreadsheets; JSON is for everything else - other scripts, APIs, downstream ComfyUI workflows, a Python program you're feeding results into. Pandas Save JSON writes a DataFrame to a JSON file at a path you specify, and like its CSV sibling it also displays the table as text right on the node so you can see what you exported. If you're building a data pipeline that ends in a file another program consumes, this is your exit node.
It's from HowToSD/ComfyUI-Data-Analysis, the pandas-in-ComfyUI pack. It shares its UI machinery with pythongosssss's show-text nodes (credited in the pack's credit/ folder), which is why the node both writes a file and renders the DataFrame as text on the canvas.
How it works
One call: dataframe.to_json(path_or_buf=file_path). The file_path input is a single-line STRING, and the path rules matter - relative paths resolve against your ComfyUI installation directory, not your current folder. data/output.json lands in ComfyUI/data/output.json. Absolute paths are unambiguous and usually what you want for anything outside ComfyUI.
As an output node it returns a list containing the DataFrame rendered as a string - that text shows up on the node itself and is embedded into the workflow JSON, so the result travels with the workflow even after the run. The default to_json format is the "split"-style records layout (columns, index, and data as separate keys), which is fine for feeding other tools and a mild surprise if you expected a clean array of records. If you need a specific JSON shape, you'll want to massage it before saving - this node takes the default and runs with it.
Inputs and output
dataframe- the table to serialize.file_path- destination path (relative to ComfyUI install dir, or absolute).
Output: a list of STRING - the DataFrame as text.
Installation
Same pack install as everything else. ComfyUI Manager: search Data analysis, install ComfyUI-Data-Analysis. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Data-Analysis.git
mv ComfyUI-Data-Analysis data-analysis # examples rely on this folder name
pip install -r requirements.txt
Restart, reload. Deps: pandas, matplotlib, seaborn, scipy, scikit-learn, openpyxl, lxml - no GPU, no models.
Gotchas
Empty file_path means a console error and no file, same as the CSV node. And know that pandas' JSON writer doesn't handle NaN gracefully by default - missing values can come out as null or break the output depending on the format. Clean or fill your nulls first with the pack's cleansing nodes if the JSON is going anywhere strict. Also, to_json doesn't preserve dtypes on read-back the way a pickle would - round-tripping through JSON is a human-readable exchange, not a lossless backup. If you need the exact same DataFrame back, save the CSV instead and reload.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dataframe | DATAFRAME | — | |
| file_path | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |