npm Registry Response to Zod

Paste a npm registry JSON payload and get a Zod z.object schema you can run inside your handler. Same shape walker as the TypeScript-mode page, but the output is a runtime-validated schema with .optional() on missing fields and z.union for nullables.

JSON input valid
Zod output

      
    

About this conversion

The npm packument has dynamic-key shapes (versions, time, dist-tags) and quietly grows fields across the registry's history. A parse at fetch time means dependency analyzers and mirror tools get an immediate validation error instead of a NoneType-style crash deep in the version walker.

Registry analyzers and dependency scanners are Node CLIs running interactively or in CI; ergonomics (named errors, .partial() for sparse responses, zod-to-json-schema for downstream tooling) matters more than the few KB of bundle. The output is a copy-paste-runnable z.object using only standard Zod primitives (z.string, z.number, z.array, z.union, .optional). Drop it into your handler, run schema.parse(body), and the rest of your code consumes a strongly typed value with no ambient unknowns.

Same shape, other validators

Other JSON shapes