Discord Webhook Message to Zod

Paste a discord webhook 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

Discord interaction and webhook handlers run on Cloudflare Workers and Vercel Edge a lot — a parse at the boundary catches snowflake-as-number bugs and missing optional fields (component arrays, attachments, embeds) before the rest of the handler tries to read them.

Discord handlers often live in a Cloudflare Worker or a Next.js route — a Zod schema gives you both runtime validation and an inferred TypeScript type from one declaration, so the handler body works against a single source of truth. 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