Validate environment variables and dotenv files against a compact typed schema before your application starts.
Package: @theworker02/envshape · Docs: GitHub Pages · Source: theworker02/envshape
- Typed
string,number, andboolenvironment schemas. - Dotenv parsing and schema-file loading.
- Strict mode for unexpected environment variables.
- Fully documented JSR API with explicit TypeScript declarations.
- Trusted publishing from GitHub Actions with provenance.
- Zero runtime dependencies.
deno add jsr:@theworker02/envshapeThen import the library API:
import { checkEnv, ENV_TYPES, PACKAGE } from "@theworker02/envshape";
const result = checkEnv(
{ PORT: "number", NAME: "string" },
{ PORT: "8080", NAME: "api" },
);
console.log(result.ok, ENV_TYPES, PACKAGE.version);checkEnv(schema, env, options)— validate an environment object.checkSchemaFile(path, env, options)— load a JSON schema and validate in one call.validateValue(type, value)— validate one primitive value.isEnvType(value)— type guard for supported schema primitive names.
parseDotenv(text)— parse dotenv-formatted text.loadDotenvFile(path)— read and parse a dotenv file.loadSchema(path)— read a JSON schema from disk.exampleFromSchema(schema)— create an empty dotenv template.formatHuman(result)— render terminal-friendly validation output.
PACKAGE— package identity and version metadata.ENV_TYPES— supported primitive names.TYPES— primitive validator table.EnvType,EnvSchema,EnvCheckResult,EnvCheckOptions,EnvError,PackageMetadata.
The repository still ships the existing Node CLI for source checkouts:
git clone https://github.com/theworker02/envshape.git
cd envshape
node src/cli.js --helpExample:
printf '{ "PORT": "number", "NAME": "string" }\n' > schema.json
PORT=8080 NAME=api node src/cli.js schema.jsonnode --testReleases are published to JSR through GitHub Actions using OIDC trusted publishing. The canonical package is @theworker02/envshape.
See CONTRIBUTING.md. Open pull requests against main.
See SECURITY.md.
MIT © 2026 theworker02