# Dotenv Tools Parse / validate / convert / mask `.env` files. Pure stdlib. ``` python scripts/run.py validate .env python scripts/run.py to-json .env python scripts/run.py from-json config.json python scripts/run.py mask .env --show 3 cat .env | python scripts/run.py mask - ``` Handles quotes, `export` prefixes, and `#` comments. --- name: env-file-tools display_name: Dotenv Tools description: "Parse, validate, and convert .env files to/from JSON, and mask secret values for safe sharing. Use for dotenv config inspection and redaction. Triggers: parse .env, env to json, json to env, mask secrets, validate dotenv." --- # Dotenv Tools Work with `.env` files: validate, convert to/from JSON, and redact secrets. ## When to use The user has a `.env` file (KEY=VALUE config) and wants to validate its syntax, turn it into JSON (or back), or mask the values so it's safe to paste/share. ## How to use Run `scripts/run.py` with a subcommand: - `python scripts/run.py validate .env` — check syntax and key names; exit 1 on errors. - `python scripts/run.py to-json .env` — emit a JSON object of the keys/values. - `python scripts/run.py from-json config.json` — emit `.env` lines from a JSON object. - `python scripts/run.py mask .env --show 3` — redact values, keeping the first 3 chars. - `cat .env | python scripts/run.py mask -` — read from stdin. Quoted values, `export ` prefixes, `#` comments, and inline comments are handled. ## Pitfalls - Keys must match `[A-Za-z_][A-Za-z0-9_]*`; bad keys fail `validate`. - `from-json` requires a top-level JSON object; arrays/objects in values are re-serialized as JSON strings, booleans become `true`/`false`, null becomes empty. - Masking keeps the key names visible — only values are redacted.
Dotenv Tools by langbot-team
Parse, validate, and convert .env files to/from JSON, and mask secret values for safe sharing.
Loading...