A lightweight CLI tool for parsing, validating, and managing .env files with schema support.
- Parse & Validate: Check
.envfiles 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
.envfiles across environments - Export: Convert
.envto JSON, YAML, or shell export format - Security: Detect potentially sensitive keys and suggest
.gitignorepatterns
pip install envparse-cliOr use directly:
python envparse.py --helpenvparse validate .envenvparse validate .env --schema .env.schema.jsonenvparse format .env --sort --output .env.formattedenvparse diff .env.development .env.productionenvparse export .env --format json > config.json
envparse export .env --format yaml > config.yaml
envparse export .env --format shell > export.shenvparse scan .envCreate 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"
}
}# Database configurationDATABASE_URL=postgresql://localhost:5432/mydbDATABASE_POOL_SIZE=10# API SettingsAPI_KEY=sk_test_1234567890API_TIMEOUT=30# ApplicationPORT=3000DEBUG=trueLOG_LEVEL=debug✓ .env is valid
✓ All required variables present
✓ All types match schema
⚠ Warning: API_KEY looks like a sensitive value (consider adding to .gitignore)
# 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.pyMIT License - see LICENSE file for details
Contributions welcome! Please open an issue or submit a pull request.