environs
simplified environment variable parsing
What it is and what it does
environs is a Python library that reads environment variables and casts them to typed Python objects—integers, booleans, dates, lists, dictionaries, and other types—with optional validation. It follows the Twelve-Factor App methodology by keeping configuration separate from code. The library can load variables from .env files without modifying os.environ, and supports prefixing, variable expansion, and custom validation rules.
You use it by instantiating an Env object, optionally calling read_env() to load a .env file, then calling type-specific methods like env.int(), env.bool(), or env.list() to retrieve and cast individual variables. It integrates with marshmallow for validation, allowing you to apply built-in validators or define custom ones. The library is framework-agnostic but has documented patterns for Flask and Django.
Use it for:
- Load database credentials and connection settings from environment variables in production deployments.
- Parse feature flags and debug settings from .env files during local development without hardcoding them.
- Validate and type-cast configuration like port numbers, timeouts, and log levels from environment variables.
- Read Docker secrets or Kubernetes ConfigMaps as environment variables with automatic type conversion.
- Build configuration management that respects the Twelve-Factor App pattern across development, staging, and production.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
environs parses environment variables into typed Python objects with validation, supporting common types like integers, booleans, dates, and collections, while optionally loading from .env files without mutating os.environ.
Yes. environs is actively maintained, has no known vulnerabilities, low install friction, and solves a common problem—parsing and validating environment variables—with a clean API. The permissive MIT license and broad Python version support (3.10+) make it a safe, practical choice for any project that needs configuration management.
Install
environs on PyPI
pip
pip install environsuv
uv add environspoetry
poetry add environsInstalling environs
Before you install
Low install friction with three lightweight runtime dependencies (python-dotenv, marshmallow, typing-extensions). The package is actively maintained with recent releases and a stable repository.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations.
Quickstart
pip install environs
from environs import env
env.read_env() # load .env file if present
max_connections = env.int("MAX_CONNECTIONS", default=10)
enable_debug = env.bool("DEBUG", default=False)
repos = env.list("REPOS", default=[])
Requires Python 3.10 or later.
Verify before relying
- Performance characteristics when parsing large numbers of environment variables.
- Compatibility with async frameworks or concurrent environment variable access patterns.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — python-dotenv, marshmallow, typing-extensions |
| Maintenance | actively maintained — 13 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,249,457/month — #2,128 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: environs-15.1.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
cabinaCabina provides class-based configuration…
permissive · top 15,000 on PyPI
envparseParses environment variables with optional type…
permissive · top 15,000 on PyPI
envsubstSubstitutes environment variables in strings…
permissive · top 15,000 on PyPI
envierEnvier extracts application configuration from…
permissive · top 1,000 on PyPI
dump-envGenerates .env files by merging an…
permissive · top 15,000 on PyPI
python-json-configLoads JSON configuration files and provides…
permissive · top 15,000 on PyPI
expandvarsExpands Unix-style variable references in…
permissive · top 5,000 on PyPI
fastapi-corsConfigures CORS settings for FastAPI…
permissive · top 15,000 on PyPI
marshmallow-enumProvides an Enum field type for Marshmallow…
permissive · top 5,000 on PyPI
python-dotenvReads key-value pairs from a .env file and sets…
permissive · top 100 on PyPI