Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

envparse

A lightweight CLI tool for parsing, validating, and managing .env files with schema support.

Features

  • Parse & Validate: Check .env files for syntax errors and missing variables
  • Schema Support: Define required variables, types, and default values
  • Format & Sort: Auto-format and alphabetically sort environment variables
  • Diff: Compare .env files across environments
  • Export: Convert .env to JSON, YAML, or shell export format
  • Security: Detect potentially sensitive keys and suggest .gitignore patterns

Installation

pip install envparse-cli

Or use directly:

python envparse.py --help

Usage

Validate a .env file

envparse validate .env

Check against a schema

envparse validate .env --schema .env.schema.json

Format and sort

envparse format .env --sort --output .env.formatted

Compare environments

envparse diff .env.development .env.production

Export to different formats

envparse export .env --format json > config.json
envparse export .env --format yaml > config.yaml
envparse export .env --format shell > export.sh

Security scan

envparse scan .env

Schema Format

Create a .env.schema.json file to define your environment variable requirements:

{
"required": ["DATABASE_URL", "API_KEY", "PORT"],
"optional": ["DEBUG", "LOG_LEVEL"],
"types": {
"PORT": "integer",
"DEBUG": "boolean",
"DATABASE_URL": "url",
"API_KEY": "string"
},
"defaults": {
"DEBUG": "false",
"LOG_LEVEL": "info",
"PORT": "3000"
}
}

Examples

Valid .env file

# Database configurationDATABASE_URL=postgresql://localhost:5432/mydbDATABASE_POOL_SIZE=10# API SettingsAPI_KEY=sk_test_1234567890API_TIMEOUT=30# ApplicationPORT=3000DEBUG=trueLOG_LEVEL=debug

Validation output

✓ .env is valid
✓ All required variables present
✓ All types match schema
⚠ Warning: API_KEY looks like a sensitive value (consider adding to .gitignore)

Development

# Clone the repository
git clone https://github.com/sickagents/envparse.git
cd envparse
# Install dependencies
pip install -r requirements.txt
# Run tests
python -m pytest tests/
# Run linter
python -m pylint envparse.py

License

MIT License - see LICENSE file for details

Contributing

Contributions welcome! Please open an issue or submit a pull request.

About

Lightweight CLI tool for parsing, validating, and managing .env files with schema support

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages