@kszongic/env-to-json-cli
v1.0.0
Published
Convert .env files to JSON from the command line — pipe-friendly, zero dependencies
Maintainers
Readme
@kszongic/env-to-json-cli
Convert .env files to JSON from the command line — pipe-friendly, zero dependencies.
Install
npm install -g @kszongic/env-to-json-cliUsage
# Read .env in current directory
env-to-json
# Read a specific file
env-to-json .env.production
# Pretty-print
env-to-json -p
# Pipe from stdin
cat .env | env-to-json
# Combine with jq
env-to-json | jq '.DATABASE_URL'Options
| Flag | Description |
|------|-------------|
| -p, --pretty | Pretty-print JSON output |
| -q, --quoted | Preserve surrounding quotes on values |
| -h, --help | Show help |
| -v, --version | Show version |
Parsing Rules
- Skips blank lines and comments (
#) - Strips
exportprefix - Strips surrounding single/double quotes (unless
--quoted) - Handles
KEY=VALUEformat
Example
# .env
DB_HOST=localhost
DB_PORT=5432
API_KEY="my-secret-key"$ env-to-json -p
{
"DB_HOST": "localhost",
"DB_PORT": "5432",
"API_KEY": "my-secret-key"
}License
MIT © 2026 kszongic
