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

dotenv-master

v1.0.0

Published

[![npm version](https://img.shields.io/npm/v/dotenv-master.svg)](https://www.npmjs.com/package/dotenv-master) [![License](https://img.shields.io/npm/l/dotenv-master.svg)](https://www.npmjs.com/package/dotenv-master) [![Build Status](https://img.shields.io

Readme

🌿 Dotenv Master

npm version License Build Status

Dotenv Master is a modern, TypeScript-first environment file parser and CLI tool for Node.js, designed to handle complex .env files, variable expansion, validation, and more.


🚀 Features

Core Parsing

  • Parse KEY=value assignments
  • Supports multi-line values
  • Handles quotes and inline comments
  • Preserves # inside quoted strings

Advanced Syntax

  • Variable expansion (${VAR}, ${VAR:-default})
  • Circular reference detection
  • Required variables ${MUST_SET:?error}
  • Escape sequences: \n, \t, \\, \$, \uXXXX

File Management

  • Supports .env, .env.local, .env.{NODE_ENV}, .env.{NODE_ENV}.local
  • Custom file paths
  • Loading precedence rules (environment & local overrides)
  • Merge strategies (override, combine, smart — partial support)

Security & Validation

  • Required variable enforcement
  • Type validation (string, number, boolean, email, URL)
  • Regex and custom validation
  • Path traversal protection

Value Processing

  • Automatic type conversion (Boolean, Number)
  • Default values for missing variables
  • Configurable variable resolution order
  • Process environment variable integration

CLI Tooling

  • dotenv-master load – load variables into process.env
  • dotenv-master validate – validate environment variables against schema
  • (Planned) dotenv-master encrypt / decrypt for secure variable management

Developer & Production Features

  • Handles large .env files (1000+ lines)
  • Streaming/line-by-line parsing
  • Detailed error reporting (file, line, snippet)
  • Cross-platform support (Linux, macOS, Windows)
  • TypeScript typings auto-generated from schema

📦 Installation

# Install via npm
npm install dotenv-master --save-dev

# Or globally for CLI access
npm install -g dotenv-master

⚙️ Usage

import { config } from "dotenv-master";

await config({
  path: ".env",
  debug: true,
  override: true,
  expand: true,
  multiline: true,
  schema: {
    DATABASE_URL: { required: true, type: "string" },
    PORT: { required: true, type: "number", allowedValues: [3000, 4000, 5000] },
    DEBUG: { required: false, type: "boolean" },
    API_KEY: { 
      required: true, 
      type: "string", 
      regex: /^[A-Z0-9]+$/, 
      custom: (value) => value.startsWith("API_") || "API_KEY must start with 'API_'" 
    }
  },
  validationMode: "throw", // or "warn"
});

console.log(process.env.DATABASE_URL);
console.log(process.env.PORT);

CLI

# Load environment variables
dotenv-master load --path .env --debug

# Validate against schema
dotenv-master validate --schema ./schema.json

Flags:

--path <file> – path to .env file

--debug – enable debug logs

--load-all-defaults – load all defaults

--override – override existing process.env

--expand – enable variable expansion

--multiline – enable multi-line values

--schema <file> – path to schema JSON

--validation-mode <strict|loose> – validation mode

📁 Example Schema

{
    DATABASE_URL: { required: true, type: "string" },
    PORT: { required: true, type: "number", allowedValues: [3000, 4000, 5000] },
    DEBUG: { required: false, type: "boolean" },
    API_KEY: { 
      required: true, 
      type: "string", 
      regex: /^[A-Z0-9]+$/, 
      custom: (value) => value.startsWith("API_") || "API_KEY must start with 'API_'" 
    }
  }

📜 License

MIT License © [Hluf Abebe]

❤️ Contributing

Contributions are welcome! Please open issues or PRs for features, bug fixes, or improvements.

🔗 Links

GitHub Repository