Nodes/Sage Utils/Parse Metadata Flexible
ComfyUI Node

Parse Metadata Flexible

Reverse-engineer any A1111 PNG's settings back into a working workflow

By arcum42·Created 2 years ago·Updated 28 days ago· 33
Parse Metadata Flexible
  • default_model_info
  • positive_string
  • negative_string
  • seed
  • steps
  • cfg
  • sampler_name
  • scheduler
  • width
  • height
  • model_info
  • lora_stack
metadata_string
default_seed0
default_steps20
default_cfg7.0
default_samplereuler
default_schedulernormal
default_width1024
default_height1024

ComfyUI's superpower is that a workflow rides along inside the PNG - "workflow included" became culture. But the older, still-everywhere format is A1111-style metadata: the flat text block under a PNG's parameters key, with Steps:, Sampler:, CFG scale:, Seed:, and the rest. Tons of images on Civitai and Reddit carry that format and nothing else, and rebuilding the settings from a screenshot of a prompt is a chore.

Parse Metadata Flexible is the reverse-engineering half of Sage Utils' metadata story. Give it an A1111 "Full" metadata string and it splits it back out into every component: positive and negative prompts, sampler settings, dimensions, and - the clever part - it tries to resolve the model and LoRAs by hash using the pack's local Civitai cache.

How it works

Feed metadata_string (the raw text block, not the image) and the node parses the familiar A1111 keys. The pack's source shows the whole grammar: Negative prompt: splits the two prompts; Steps:, Sampler:, Scheduler type:/Schedule type:, CFG scale: and Seed: are each extracted; Size: gives width and height. It also handles the Model hash: field and Lora hashes: entries, and cleans <lora:name:weight> tokens out of the prompt while turning them into stack entries.

The sampler name gets the fun treatment: A1111 and ComfyUI call samplers different things, so it reverse-maps Civitai/A1111 names (like "DPM++ 2M Karras") back to ComfyUI's names, pulling the scheduler out at the same time. Model and LoRA hashes are matched against the pack's cache - the same sage_cache_hash.json / sage_cache_info.json files that the metadata-creation side writes - and the matching model_info / lora_stack are handed to you ready for the loader nodes.

The outputs that matter

It's a big output bank, and it's the point:

  • positive_string and negative_string - straight into your prompt nodes or CLIP encoders.
  • seed, steps, cfg, sampler_name, scheduler - the exact generation settings, ready to feed a KSampler or a Sampler Info node.
  • width / height - for Empty Latent Passthrough.
  • model_info and lora_stack - resolved model and LoRA bundle, wireable into Load Models + Loras and Construct Metadata.

If a field is missing from the metadata, the defaults kick in - default_seed, default_steps (20), default_cfg (7.0), default_sampler (euler), default_scheduler (normal), default_width/default_height (1024), and optionally default_model_info if the hash can't be resolved.

Installation

Same pack as everything else here. ComfyUI Manager, search "Sage Utils", or:

cd ComfyUI/custom_nodes
git clone https://github.com/arcum42/ComfyUI_SageUtils
cd ComfyUI_SageUtils
pip install -r requirements.txt

Restart ComfyUI. Only dependency is dynamicprompts.

Where people get burned

The model-hash resolution only works if the pack has already hashed and cached those files - run Model Scan & Report once so the cache exists, or the lookup silently falls back to default_model_info. And remember the format it speaks: this parses A1111 "Full" format text, not the JSON blobs some newer tools embed. If you're copying metadata out of an image viewer, make sure you grab the parameters block, not a rendered description. For the reverse of this node - building A1111 strings from a workflow - the pack's Construct Metadata nodes are the other half of the same pipeline.

CategorySage Utils/metadata

Inputs (9)

NameTypeDefaultDescription
metadata_stringSTRINGThe metadata string to parse.
default_seedoptINT0Default seed used when the metadata does not specify one.
default_stepsoptINT201–10000Default steps used when the metadata does not specify them.
default_cfgoptFLOAT7.00–100Default CFG scale used when the metadata does not specify it.
default_sampleroptCOMBOeulerDefault sampler to use when the metadata string does not specify one.
default_scheduleroptCOMBOnormalDefault scheduler to use when the metadata string does not specify one.
default_widthoptINT1024Default width used when the metadata does not specify dimensions.
default_heightoptINT1024Default height used when the metadata does not specify dimensions.
default_model_infooptMODEL_INFODefault model info used when the metadata string does not identify a model.

Outputs (11)

NameTypeDescription
positive_stringSTRINGExtracted positive prompt string.
negative_stringSTRINGExtracted negative prompt string.
seedINTExtracted seed value.
stepsINTExtracted number of steps.
cfgFLOATExtracted CFG scale.
sampler_nameCOMBOExtracted sampler name.
schedulerCOMBOExtracted scheduler name.
widthINTExtracted image width.
heightINTExtracted image height.
model_infoMODEL_INFOExtracted default model info from metadata, if available.
lora_stackLORA_STACKExtracted LoRA stack information from the metadata.