Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

envparse-cli

A lightweight command-line tool for parsing, validating, and manipulating .env files with zero dependencies.

Features

  • Parse.env files and output as JSON, YAML, or shell export format
  • Validate environment variable syntax and detect common issues
  • Merge multiple .env files with conflict detection
  • Extract specific variables by key or pattern
  • Template support for variable substitution (${VAR} syntax)
  • Diff two .env files to see what changed
  • Sort variables alphabetically or by custom order
  • Comment preservation when editing files

Installation

npm install -g envparse-cli

Or use directly with npx:

npx envparse-cli parse .env

Usage

Parse and validate

envparse parse .env
envparse parse .env --format json
envparse parse .env --format yaml

Validate syntax

envparse validate .env

Merge multiple files

envparse merge .env .env.local .env.production

Extract specific variables

envparse extract .env DATABASE_URL API_KEY
envparse extract .env --pattern "^AWS_"

Diff two files

envparse diff .env.old .env.new

Sort variables

envparse sort .env --output .env.sorted

Template substitution

envparse template .env.template --vars .env.values

Examples

Input .env:

# Database configuration
DATABASE_URL=postgresql://localhost:5432/mydb
DATABASE_POOL_SIZE=10
# API Keys
API_KEY=secret123
API_TIMEOUT=30

Parse to JSON:

$ envparse parse .env --format json
{
"DATABASE_URL": "postgresql://localhost:5432/mydb",
"DATABASE_POOL_SIZE": "10",
"API_KEY": "secret123",
"API_TIMEOUT": "30"
}

Validate:

$ envparse validate .env
✓ .env is valid (4 variables, 2 comments)

Extract pattern:

$ envparse extract .env --pattern "^DATABASE_"
DATABASE_URL=postgresql://localhost:5432/mydb
DATABASE_POOL_SIZE=10

API

Can also be used as a Node.js library:

const{ parse, validate, merge }=require('envparse-cli');constenv=parse('.env');console.log(env.DATABASE_URL);constisValid=validate('.env');constmerged=merge(['.env','.env.local']);

License

MIT

Contributing

Pull requests welcome! Please ensure tests pass with npm test.

About

A lightweight CLI tool for parsing, validating, and manipulating .env files

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages