Case study · Typed environment validation2026

type-env

Environment variables are the seam between your code and every machine it runs on. They should fail loudly at boot, not mysteriously at 2am.

Year2026
RoleCreator
StackTypeScript, JSON Schema, npm
type-env project cover

The problem

Untyped environment variables make configuration errors invisible until a specific code path runs. A missing or malformed value can look like an application bug.

Most validation libraries bring a framework, a runtime dependency, or a type-generation step that is heavier than the problem.

What I built

  • A zero-dependency TypeScript API that validates process.env against JSON Schema.
  • Safe coercion for numbers, booleans, and other primitive values before they reach application code.
  • Typed output so consumers get autocomplete and compile-time confidence, not stringly typed lookups.
  • A CLI that validates a schema against an environment file, with readable errors that point to the exact key.

System shape

Request path
Sourceprocess.envRaw strings
ValidateJSON SchemaTypes + coercion
OutputTyped configFail-fast startup
process.env → schema validation → coercion → typed config → application boot

Decisions and tradeoffs

01

Zero dependencies

Configuration validation runs at boot in every environment. It should not drag a dependency tree into the runtime.

02

Fail at the boundary

The best time to discover a bad env var is before the application starts, with a message that names the key and the expectation.

03

Types follow validation

The runtime check and the TypeScript type describe the same shape, so the compiler and the process agree.

Outcome

A small, focused developer tool with 1 GitHub star, built to make configuration failures obvious and typed at the earliest possible moment.

What stayed with me

Configuration errors should be boring: one clear message at boot, not a stack trace after the first request.

Next case study
PodVoice