Skip to content


goodconf is a thin wrapper over Pydantic's settings management. Allows you to define configuration variables and load them from environment or JSON/YAML file. Also generates initial configuration files and documentation for your defined configuration.


pip install goodconf or pip install goodconf[yaml] if parsing/generating YAML files is required.

Basic Usage

Define the configuration object in

import base64
import os

from goodconf import GoodConf, Field
from pydantic import PostgresDsn

class AppConfig(GoodConf):  # type: ignore
    """Configure my application."""

    debug: bool
    database_url: PostgresDsn = "postgres://localhost:5432/mydb"
    secret_key: str = Field(
        initial=lambda: base64.b64encode(os.urandom(60)).decode(),
        description="Used for cryptographic signing. "

    class Config:
        """Define the default files to check."""

        default_files = [

config = AppConfig()

To load the configuration use config.load(). If you don't pass any file to load(), then the default_files will be read in order.

Remember that environment variables always take precedence over variables in the configuration files.

For more details see Pydantic's docs for examples of loading:


Last update: 2022-11-29