npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gen-envex

v1.0.2

Published

CLI tool to generate a .env.example from your .env file — strips all values, keeps keys safe to commit

Readme

gen-envex - Generate .env.example

🔒 Automatically generate a .env.example from your .env file by removing all secret values while preserving variable names, comments, and formatting.

npm version License Node.js

🔗 Quick Links

  • Repository: https://github.com/AniketDey06/gen-envex
  • npm: https://www.npmjs.com/package/gen-envex

✨ Features

  • 🔐 Removes all secret values automatically
  • 📝 Preserves comments and blank lines
  • 📄 Keeps environment variable names intact
  • ⚡ Simple CLI with zero configuration
  • 📂 Supports custom input and output files
  • 🖥️ Works on Windows, macOS, and Linux

📖 Why use gen-envex?

Your .env file contains sensitive information such as API keys, database passwords, and tokens, so it should never be committed to Git.

However, your teammates still need to know which environment variables are required.

gen-envex automatically creates a safe .env.example by stripping all values while preserving the structure of your original file.

📥 Example

Input (.env)

# Database configuration
DB_HOST=localhost
DB_PORT=5432
DB_PASSWORD=supersecret123

# API Keys
STRIPE_SECRET_KEY=sk_live_abc123
NEXT_PUBLIC_API_URL=https://api.example.com

Output (.env.example)

# Database configuration
DB_HOST=
DB_PORT=
DB_PASSWORD=

# API Keys
STRIPE_SECRET_KEY=
NEXT_PUBLIC_API_URL=

📦 Installation

Install globally

npm install -g gen-envex

Install as a development dependency

npm install --save-dev gen-envex

Use without installing

npx gen-envex

📄 Standalone Script

If you prefer not to install gen-envex, you can use the standalone script instead.

Simply download or copy generate-env-example.js into your project and run it directly with Node.js.

Code Link - https://github.com/AniketDey06/gen-envex/blob/main/generate-env-example.js

node generate-env-example.js

You can also integrate it into your project's package.json scripts.

{
  "scripts": {
    "gen:env": "node generate-env-example.js",
    "dev": "node generate-env-example.js && next dev"
  }
}

This keeps your .env.example up to date every time you start your development server—without installing the CLI globally or as a project dependency.

🚀 Usage

Basic usage

Generate .env.example from .env in the current directory.

gen-envex

or

npx gen-envex

Custom input and output

gen-envex --input .env.local --output .env.example
gen-envex --input config/.env --output config/.env.example

📜 package.json Scripts

Generate manually

{
  "scripts": {
    "gen:env": "gen-envex"
  }
}

Run:

npm run gen:env

or

pnpm gen:env

or

yarn gen:env

Generate automatically before development

{
  "scripts": {
    "dev": "gen-envex && next dev"
  }
}

Now every time you run:

npm run dev

(or pnpm dev / yarn dev), your .env.example will always stay up to date.

⚙️ CLI Options

| Option | Description | |---------|-------------| | --input | Path to the source .env file | | --output | Path where .env.example will be generated |

Example:

gen-envex --input .env.local --output .env.example

✅ Behavior

gen-envex preserves your file structure while removing sensitive values.

  • ✅ Removes all environment variable values
  • ✅ Preserves comments (# ...)
  • ✅ Preserves blank lines
  • ✅ Preserves variable order
  • ✅ Ignores invalid lines without =
  • ✅ Supports both Unix (\n) and Windows (\r\n) line endings

🤝 Contributing

Contributions are welcome!

If you'd like to improve gen-envex, feel free to:

  • Open an issue

  • Submit a pull request

  • Suggest new features

  • Repository: https://github.com/AniketDey06/gen-envex (Do leave a ⭐)

👨‍💻 Authors

  • Aniket Dey - https://aniketdey.in
  • Arun Mondal - https://github.com/ArunKM-Git

📄 License

This project is licensed under the MIT License.