package.json to Zod

Paste a package.json 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

Tools that read package.json (build wrappers, monorepo managers, registry analyzers) crash hard when a manifest is malformed or uses an unfamiliar field shape. A parse turns a malformed exports map into one named error at the top of the tool, not a deep-property crash twenty calls in.

Tools that read package.json are typically Node CLIs and build scripts where startup time is dominated by the npm resolver, not the validator — Zod's chained API is the more familiar choice for the typescript-first audience that builds these tools. 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