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 🙏

© 2025 – Pkg Stats / Ryan Hefner

env-aligner

v2.0.0

Published

Validate, align, and clone env files (e.g. .env) using a schema file (e.g. .env.example).

Downloads

19

Readme

Env Aligner

Env Aligner is a lightweight CLI tool that helps you validate and align environment variables between .env and .env.example files.
It checks for missing keys, empty values, and extra variables, and optionally formats .env files to match the schema.

Here's what env-aligner output looks like:
Example

Installation

npm install env-aligner

Features

Env Aligner recursively searches your project directories and provides the following features:

  1. Missing Key: Detects keys defined in the schema file (e.g., .env.example) but missing from the .env file.
  2. Missing Value: Detects variables that exist in .env but have no assigned value.
  3. Extra Key: Detects keys in .env that are not defined in the schema file. This is only checked in strict mode.
  4. Align: Automatically aligns the order and structure of the .env file based on the schema. This feature requires strict mode to be enabled.
  5. Clone: Creates a new .env file based on the schema file if none exists.

Usage

CLI Options

| Option | Description | Default | |---------------|-----------------------------------------------------------------------------|-------------------| | --dir | Root directory to scan. | process.cwd() | | --schema | Schema file name (usually .env.example). | .env.example | | --env | Env file name to validate or align. | .env | | --strict | Enable strict mode: warns about extra keys in .env not in the schema. | Not enabled (unless flag is present) | | --align | Enable align mode: auto-fix .env format based on schema. ⚠️ Only works with --strict. | Not enabled (unless flag is present) | | --clone | Clone schema to env file if env does not exist in the folder. | Not enabled (unless flag is present) |

Examples:

npx env-aligner
npx env-aligner --dir .devcontainer --schema config.example --env config.env
npx env-aligner --clone
npx env-aligner --strict --align

Programmatic Usage (Optional)

Although Env Aligner is primarily designed for use via the CLI, it also supports programmatic usage in JavaScript environments.

⚠️ Note: Programmatic usage is only supported in CommonJS (require) environments.
If your project uses "type": "module" (ESM), consider using the CLI instead.

const envAligner = require('env-aligner')

envAligner({
  rootDir: string, // Root directory to scan (default: process.cwd())
  fileNames: {
    schemaName: string, // Schema file name (e.g., '.env.example')
    envName: string     // Env file name to validate (e.g., '.env')
  },
  mode: {
    isStrict: boolean,  // Enable strict mode (extra key detection)
    isAlign: boolean    // Enable align mode (auto format fix)
  },
  isClone: boolean       // Whether to generate the env file if missing
})

Changelog

See CHANGELOG.md for full version history.

License

MIT © 2025 Jeremy Ho & MJC


Got suggestions or questions? Open an issue or drop us a message — we’d love to hear from you!