Factory.ai

Open-Source Wikis

/

Stable Diffusion WebUI

/

Reference

/

Configuration

AUTOMATIC1111/stable-diffusion-webui

Configuration

There are three layers of configuration, all readable from shared:

  1. Command-line flags — parsed once at boot in modules/cmd_args.py. Available as shared.cmd_opts. Read-only.
  2. User options — declared in modules/shared_options.py, persisted to config.json. Available as shared.opts. Edited via the Settings tab or POST /sdapi/v1/options.
  3. UI defaults — slider/dropdown initial values stored in ui-config.json by modules/ui_loadsave.py.

This page lists the most-used flags and the categories of options. The exhaustive list lives in the source.

Command-line flags

Roughly 130 flags. Defined with parser.add_argument(...) in modules/cmd_args.py. Common ones:

Network / surface

| Flag | Effect | | ----------------------------------------------------------------- | ----------------------------------------------------- | -------------------------- | | --listen | Bind to 0.0.0.0 | | --port N | Listen on port N (default 7860, 7861 for --nowebui) | | --api | Enable the FastAPI routes alongside the UI | | --nowebui | Run as headless API server | | --share | Open a Gradio public tunnel | | --ngrok TOKEN | Tunnel via ngrok | | --subpath PATH | Host under a sub-path | | --cors-allow-origins=URLs, --cors-allow-origins-regex=PATTERN | CORS allow list | | --gradio-auth USER:PASS, --gradio-auth-path FILE | UI HTTPBasic | | --api-auth USER:PASS, --api-auth-file FILE | API HTTPBasic | | --api-server-stop | Register /sdapi/v1/server-stop | | --api-log | Log every API request | | --enable-insecure-extension-access | Allow extension installs over the network | | --disable-all-extensions all | extra | Disable extensions at boot | | --disable-extra-extensions | Disable user extensions, keep built-ins | | --tls-keyfile FILE, --tls-certfile FILE | TLS termination | | --gradio-allowed-path PATH | Whitelist additional paths Gradio can serve |

Hardware / memory

| Flag | Effect | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | --------- | ------------------------------------ | | --xformers | Enable xFormers cross-attention | | --force-enable-xformers | Enable even if compatibility check fails | | --xformers-flash-attention | xFormers + Flash Attention (SD2.x only) | | --opt-split-attention, --opt-split-attention-v1, --opt-split-attention-invokeai, --opt-sub-quad-attention, --opt-sdp-attention, --opt-sdp-no-mem-attention, --disable-opt-split-attention | Pick attention backend | | --medvram, --medvram-sdxl, --lowvram | VRAM optimisations | | --lowram | Load weights to VRAM rather than RAM | | --no-half | UNet in fp32 | | --no-half-vae | VAE in fp32 | | --upcast-sampling | Upcast just the sampler math | | --precision full | half | autocast | Default precision (default autocast) | | --use-cpu MODULE [MODULE ...] | Force specific submodules to CPU (all to force everything) | | --use-ipex | Intel XPU | | --skip-torch-cuda-test | Don't fail if CUDA isn't available | | --disable-nan-check | Don't reject NaN-producing models |

Paths

Flag Effect
--data-dir PATH Override the data directory (config, outputs, …)
--models-dir PATH Override the models directory
--ckpt FILE Use a specific checkpoint
--ckpt-dir DIR, --vae-dir DIR, --embeddings-dir DIR, --hypernetwork-dir DIR Override individual model dirs
--ui-config-file PATH, --ui-settings-file PATH Override config files

Debug / dev

Flag Effect
--loglevel LEVEL Log level
--log-startup Verbose boot
--gradio-debug Gradio's verbose mode
--dump-sysinfo Write a sanitised sysinfo JSON and exit
--reinstall-torch, --reinstall-xformers Force reinstall on next boot
--skip-prepare-environment, --skip-install Skip env prep
--update-all-extensions, --update-check Update extensions / check for updates
--allow-code Enable the custom-code script
--test-server Use a stub model for tests
--do-not-download-clip Don't auto-download CLIP

For the complete list, run python launch.py --help or read modules/cmd_args.py.

User options (opts)

Declared in modules/shared_options.py (~50 KB, ~400 settings). Each call to options_templates.update(options_section(...)) adds a section visible in the Settings tab.

The sections, in order:

Section Examples
Saving images filename pattern, jpeg/avif quality, save grids
Paths for saving per-tab output dirs
Saving to a directory always-save, paste-info
Upscaling ESRGAN tile size, RealESRGAN models
Face restoration enable, weight
System memory monitor, GIT executable, profiler
Profiling torch profiler options (added v1.8)
API api_enable_requests, api_forbid_local_requests, api_useragent
Training TI / hypernet defaults
Stable Diffusion active checkpoint, VAE, clip-skip, hires-fix defaults
SDXL refiner ratio, etc.
Compatibility legacy emphasis, old hires-fix
VAE active VAE, fp32
img2img inpainting masking, color correction
Optimizations token-merging, hypertile, AND-composable defaults
Sampler parameters UniPC variant, eta, schedule type defaults
Hidden settings the user can show/hide from the Settings UI
Postprocessing always-apply postprocessors after generation
Live previews preview mode (Approx vs TAESD), every-N steps
Defaults UI defaults written to ui-config.json
User interface quicksettings list, hires-fix layout, theme
Infotext what to write into PNG metadata
Settings localisation, keyboard shortcuts
Gallery columns, filters
Extra Networks card size, sort, refresh

Each option declares an OptionInfo with default, label, component class, and optional onchange and comment_after (for tooltips). Extensions add their own via script_callbacks.on_ui_settings.

The on-disk format of config.json is a flat JSON dict from option key to value:

{
  "samples_save": true,
  "outdir_samples": "",
  "sd_model_checkpoint": "v1-5-pruned-emaonly.safetensors [6ce0161689]",
  "...": "..."
}

UI defaults

ui-config.json records "what the user has clicked on for each control". When the user changes a slider or dropdown, the new value is written to this file (if opts.save_ui_settings_to_file is on). On the next page load, modules/ui_loadsave.py restores those values.

This file is per-user and machine-local. It is not versioned with the repo.

Other config files in the data dir

File Purpose
config.json opts
ui-config.json UI control defaults
cache.json Model hashes, extension commit info, sampler caches
styles.csv Saved prompt styles
params.txt Last-used generation parameters
tmp/ Gradio temp uploads
log/ Generation log

The data dir is --data-dir (defaults to repo root).

Environment variables

A handful of env vars are honoured outside of cmd_args.py:

Var Effect
COMMANDLINE_ARGS Read by webui-user.sh/.bat into the launch flags
TORCH_COMMAND Override the pip command used to install torch
XFORMERS_PACKAGE Override the xFormers pip command
REQS_FILE Override the requirements file path
python_cmd, venv_dir Used by webui.sh/.bat for venv setup
SD_WEBUI_LOG_LEVEL Default log level
SD_WEBUI_RESTARTING Set to 1 during in-process UI reload to suppress auto-launch
IIB_LIST Used by some extensions for the image browser; not core

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Configuration – Stable Diffusion WebUI wiki | Factory