Sign In

Civitai Helper - Civitai.Info to A1111 JSON Convert Script v2

1
Civitai Helper - Civitai.Info to A1111 JSON Convert Script v2

About

This is a script that takes Civitai Helper's .civitai.info files and make json files for use in Automatic1111's webUI Lora browser, filling in trigger words, SD version and other info.

It's modified from mrkuenning579's script here: https://civitai.com/models/432395/civitai-helper-civitaiinfo-to-a1111-json-convert-script

From the original page:

It captures the following data:

The Activation Words
The URL the file was downloaded from
The Model the file was trained on
The Description

It will store all of that in the JSON to be easily accessed from the WebUI.


I only modified it slightly. It will not overwrite settings in a pre-existing json file, like trigger words or SD version, except:

  • Removes Lora tags (<Lora:x:y>) in trigger word section (I see some Lora creators use this, which is not helpful)

  • Removes the word "None" set in trigger word section (Same thing, not so helpful)

  • Unless set with the -o switch (overwrite, see below), leaves SD version untouched if set.

(The latter point was my main gripe with the original script, as it kept overwriting my corrections)

Update 2 (2025.03.16 - v2.91):

  • Just added some options via switches (My version numbering sucks)

Update (2025.03.16 - v2.9):

  • Now also adds the base model information to the beginning of the description field. See base model at-a-glance from the Lora browser,
    (IE illustrious / Pony / SDXL, etc. Though there's still the possibility it's a combo lora, working for several types of base models...)

Usage:

Just drop it in the lora folder, or point it to your lora folder and run it via Python. It will traverse the folder structure recursively, also following symbolic links.

  • Run Civitai Helper extension, "Scan models for Civitai". Make sure "Lora" is ticked. To get those .civitai.info files.

  • Then run the script from the lora base folder (If using Auto1111, probably /stable-diffusion-webui/models/Lora)

python3 civitai-2-json-v2.91.py

Or point it to your lora folder from anywhere, using the "-d" switch:

python3 civitai-2-json-v2.91.py -d your/lora/folder

Optional switches:

  • -b for adding base model info to beginning of the json description field (visible in Lora browser)

  • -d for setting lora base folder / directory path

  • -o for overwriting any existing SD version in json with SD version from the civitai.info file

  • -v for verbose mode (truncated paths)

  • -vv for very verbose mode (full paths)

  • -h for help (basically you don't need it now that you've read this).

Regardless of switches it will print out any paths missing .civitai.info files at the end in full, if found.

Example output:

$python3 civitai-2-json-v2.91.py

Enumerating files in all directories...

  509 civitai.info files to process.
    0 model files without corresponding .info files.
      Starting processing...

Progress: [============================================================================>] 100% (509/509)

  -------------- Processing Summary --------------
     JSON files skipped (no changes)      : 509
     JSON files modified                  :   0
     New JSON files created               :   0
    ----------------------------------------------
 ==> Total .civitai.info files processed  : 509
    ==============================================
     - Model files without .info files    :   0

All done

If it finds model files without .info files, you probably need to run Civitai Helper first.

Note: No guarantee that it's fit for any particular purpose whatsoever, use at your own risk and all that. No license in the original script, so there's no license here either (public domain). Modify as you wish.

Note 2: Made with help from Claude Sonnet 3.5 / 3.7, I'm not that good with Python.

(Also I didn't have a fitting image, and now I can't remove it :p)

(And yes I posted an earlier version before, very briefly)

That's all.

Edits: clarifications and typos.

1

Comments