Comfy-Org/ComfyUI · error · ValueError
Unsupported text format: {format!r}
Error message
Unsupported text format: {format!r} What it means
The SaveText-style node maps a format combo value to a file extension via a FORMAT_EXTENSIONS dict. If the format value is not a key in that dict (extension lookup returns None), the node refuses to save. In practice this happens when the workflow JSON carries a stale or hand-edited format value not present in the node's current combo options.
Source
Thrown at comfy_extras/nodes_text.py:39
node_id="SaveText",
search_aliases=["save text", "write text", "export text"],
display_name="Save Text",
category="text",
description="Save text content to a file in the output directory.",
inputs=[
io.String.Input("text", force_input=True),
io.String.Input("filename_prefix", default="ComfyUI"),
io.Combo.Input("format", options=list(cls.FORMAT_EXTENSIONS), default="txt"),
],
outputs=[io.String.Output(display_name="text")],
is_output_node=True,
)
@classmethod
def execute(cls, text, filename_prefix, format):
extension = cls.FORMAT_EXTENSIONS.get(format)
if extension is None:
raise ValueError(f"Unsupported text format: {format!r}")
full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(
filename_prefix,
folder_paths.get_output_directory(),
1,
1,
)
file = f"{filename}_{counter:05}.{extension}"
filepath = os.path.join(full_output_folder, file)
if extension == "json":
# tries to pretty print otherwise saves normally
try:
data = json.loads(text)
with open(filepath, "w", encoding="utf-8") as f:
json.dump(data, f, indent=2, ensure_ascii=False)
except json.JSONDecodeError:View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Re-select the format in the node UI so the widget value matches a current option (e.g. txt, json)
- If submitting via API, set format to one of the keys exposed by the node's define_schema combo options
- Remove stale widget values from the workflow JSON
Example fix
# API prompt: use a listed option # before "format": "markdown" # after "format": "txt"
Defensive patterns
Strategy: validation
Validate before calling
valid = set(SaveText.FORMAT_EXTENSIONS) # from the node class
if format not in valid:
format = "txt" Type guard
def is_supported_text_format(fmt: str, node_cls) -> bool:
return fmt in node_cls.FORMAT_EXTENSIONS Prevention
- Always re-select combo widgets after loading old workflows
- When driving the API, pull combo options from the node schema instead of hardcoding strings
When it happens
Trigger: Executing a workflow where the format widget value was serialized as something not in FORMAT_EXTENSIONS — e.g. an old value from a previous node version, a hand-edited workflow file, or a client sending an arbitrary combo string that bypasses UI validation.
Common situations: Loading old workflows after the node's supported format list changed; API-driven prompt submissions with an unvalidated combo string; copied nodes between graphs carrying a removed format option.
Related errors
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/22295bd02a228afb.
Report an issue: GitHub.