Skip to main content

Validate .env files against a schema. Catch missing and invalid environment variables before runtime.

Project description

envlint

Language-agnostic .env validation. One schema, any stack.

PyPI version License: GPL v3

Validate your .env files in CI before your app even starts. Works with Python, Node, Go, Rust, Ruby—any language that uses environment variables.

Why envlint?

Existing solutions like pydantic-settings (Python) or envalid (JavaScript) only work within their own language. You need to run your app to validate your config.

envlint is different:

  • Language-agnostic — Define your schema once, validate from any CI pipeline
  • Catches issues at build time — Before your app crashes in production
  • No code changes — Just a YAML schema and a CLI command
  • No SDK or runtime dependency — Your app doesn't need to know envlint exists
# Your app crashes in production because...
KeyError: 'DATABASE_URL'

# Or silently uses wrong values...
API_URL=htpp://api.example.com  # typo in scheme
PORT=not_a_number               # string where int expected

envlint catches these in CI, not production.

Installation

pip install envlint

Quick Start

1. Create a schema file (.env.schema):

DATABASE_URL:
  type: url
  required: true

API_KEY:
  type: string
  required: true
  pattern: "^sk_[a-zA-Z0-9]{32}$"

PORT:
  type: port
  required: false
  default: "3000"

DEBUG:
  type: bool
  required: false

2. Run envlint:

envlint check

3. See results:

┌─────────────────────────────────────────────────┐
│ envlint                                        │
├─────────────────────────────────────────────────┤
│ ✓ All 4 variables validated successfully       │
└─────────────────────────────────────────────────┘

Or if there are errors:

┌─────────────────────────────────────────────────┐
│ Errors                                          │
├──────────────┬────────────────────┬─────────────┤
│ Variable     │ Error              │ Value       │
├──────────────┼────────────────────┼─────────────┤
│ DATABASE_URL │ required variable  │ -           │
│              │ is missing         │             │
│ API_KEY      │ must match pattern │ invalid_key │
│ PORT         │ must be a port     │ abc         │
│              │ number (0-65535)   │             │
└──────────────┴────────────────────┴─────────────┘

Exit code is 1 on errors, 0 on success. Perfect for CI/CD.

Schema Format

Supported Types

Type Description Example
string Any string (default) my-value
int Integer 42
float Decimal number 3.14
bool Boolean (true/false, 1/0, yes/no) true
url Valid URL with scheme https://api.example.com
email Email address user@example.com
port Port number (0-65535) 8080
path File path /var/log/app.log

Full Schema Options

MY_VARIABLE:
  type: string          # Type (see above)
  required: true        # Is this variable required?
  default: "value"      # Default value if missing
  pattern: "^[A-Z]+$"   # Regex pattern to match
  description: "..."    # Documentation
  choices:              # Allowed values
    - option1
    - option2
  min: 0                # Minimum (for numeric types)
  max: 100              # Maximum (for numeric types)

Shorthand Syntax

For simple variables, use shorthand:

# These are equivalent:
API_KEY: string
API_KEY:
  type: string
  required: true

# Just the name = required string
SECRET:

CLI Usage

# Basic validation
envlint check

# Specify files
envlint check --env .env.production --schema env.schema.yml

# Include system environment variables
envlint check --system

# Strict mode (fail on undefined variables)
envlint check --strict

# Verbose output (show warnings)
envlint check --verbose

# Quiet mode (only output on error)
envlint check --quiet

# Generate schema from existing .env
envlint init --from-env .env

# Create template schema
envlint init

CI/CD Integration

GitHub Actions

- name: Validate environment
  run: |
    pip install envlint
    envlint check --env .env.example --schema .env.schema

Pre-commit Hook

# .pre-commit-config.yaml
repos:
  - repo: local
    hooks:
      - id: envlint
        name: envlint
        entry: envlint check
        language: system
        pass_filenames: false

Docker Build

FROM python:3.11
RUN pip install envlint
COPY .env.schema .
COPY .env .
RUN envlint check
# ... rest of build

License

GPL v3

Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envlint-0.1.0.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envlint-0.1.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file envlint-0.1.0.tar.gz.

File metadata

  • Download URL: envlint-0.1.0.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for envlint-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a60715d643aee33fed7a6e953d492ba71ef0bd17b44b6b0c0ec8092b4f674279
MD5 d50877b1dd855d417971d44fd734dd25
BLAKE2b-256 073bb5a4bd7cf03633e3c4428447a9eee0c16e9a2d4ceae102f345bc036e2e7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for envlint-0.1.0.tar.gz:

Publisher: publish.yml on cainky/envlint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file envlint-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: envlint-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for envlint-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 213f334c5f01b5c08cd40b18a9fcd89d2f9dfbbfcb7ba942a6281151d9026c8e
MD5 53401687b821b5032df38d007743dc94
BLAKE2b-256 eabacd50ac3c7e20a7cb180c7b84deffc261b832901eda0483aad7c27432bc9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for envlint-0.1.0-py3-none-any.whl:

Publisher: publish.yml on cainky/envlint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page