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

env-schema-docs

v0.2.0

Published

Update environment variable docs from a JSON schema

Readme

env-schema-docs

Command line tool to update environment variable documentation from a JSON schema, intended for use with the env-schema utility.

Install

npm i env-schema-docs

Usage

Readmes

Run the readme command to inject a markdown table into a markdown file. There must be <!-- ENV_VARS_START --> and <!-- ENV_VARS_END --> comments in the file, the table will be injected between them.

npx envdocs readme ./schema.json ./README.md

Updated file:

# Environment variables
<!-- ENV_VARS_START -->
| Name | Description       | Default | Required |
| ---- | ----------------- | ------- | -------- |
| PORT | Port to listen on | 3000    | Yes      |
<!-- ENV_VARS_END -->

The schema must be a valid JSON Schema, either as a JSON file or a JavaScript file that exports the schema as the default export, or a named export of "schema".

The buildTable() function can also be used programatically:

import { buildTable } from "env-schema-docs"

const schema = {
  type: 'object',
  required: ['PORT'],
  properties: {
    PORT: {
      description: 'Port to listen on'
      type: 'number',
      default: 3_000
    }
  }
}

const table = buildTable(schema)
console.log(table)
/* output:
| Name | Description       | Default | Required |
| ---- | ----------------- | ------- | -------- |
| PORT | Port to listen on | 3000    | Yes      |
*/

Dotenv files

The dotenv command allows you to create a env file from a JSON schema. It can also be used to update an env file with new variables while preserving any existing values.

For the schema:

{
  "type": "object",
  "required": ["PORT"],
  "properties": {
    "PORT": {
      "description": "Port to listen on"
      "type": "number",
      "default": 3000
    }
  }
}

The command:

npx envdocs dotenv ./schema.json ./.env

Will create:

PORT=

Comments can be included using the --comments or -c flag, they will include the description text, whether the variable is required and any default values:

npx envdocs dotenv ./schema.json ./.env --comments
# Port to listen on
# Required. Default: 3000
PORT=

You can use the schema default values as the variable values by using the --defaults or -d flag.

npx envdocs dotenv ./schema.json ./.env --defaults
PORT=3000

You can update an existing dotenv file to include new variables or comments and retain any existing variable values by using the --update or -u flag:

npx envdocs dotenv ./schema.json ./.env --update

Help

Help can be accessed using the help command. For command specific help, use help followed by the command you need help with:

$ npx envdocs help
Generate environment variable docs from a JSON schema

VERSION
  env-schema-docs/0.1.0 darwin-arm64 node-v24.15.0

USAGE
  $ envdocs [COMMAND]

COMMANDS
  help     Display help for envdocs or an envdocs command
  readme   Inject a markdown table of environment variables into a readme file
  dotenv   Generate or update a dotenv file
$ npx envdocs help readme
Inject a markdown table of environment variables into a readme file

USAGE
  $ envdocs readme SCHEMAPATH READMEPATH

ARGUMENTS
  SCHEMAPATH  The path to the JSON schema, either a JSON file or a JS file that
              exports a schema as the default value or a name export of "schema"
  READMEPATH  The path to the readme file

DESCRIPTION
  Inject a markdown table of environment variables into a readme file. The table
  will appear between the "<!-- ENV_VARS_START -->" and "<!-- ENV_VARS_END -->"
  comments within the file.

EXAMPLES
  $ envdocs readme ./schemas/env.json ./README.md
$ npx envdocs help dotenv
Generate or update a dotenv file

USAGE
  $ envdocs dotenv SCHEMAPATH DOTENVPATH [-c] [-d] [-u]

ARGUMENTS
  SCHEMAPATH  The path to the JSON schema, either a JSON file or a JS file that
              exports a schema as the default value or a name export of "schema"
  READMEPATH  The path to the dotenv file

FLAGS
  -c, --comments  Comment each variable with the schema description
  -d, --defaults  Set the schema defaults as the variable values
  -u, --update    If the file already exists, preserve variable values

DESCRIPTION
  Generate or update a dotenv file

EXAMPLES
  $ envdocs dotenv ./schemas/env.json ./.env.example -c -d
  $ envdocs dotenv ./schemas/env.json ./.env -u