tRPC Input to Zod

Paste the JSON your client sends to a tRPC procedure and get the Zod schema for .input(). Works for query and mutation procedures, App Router and Pages Router, with cursor pagination, filter bags, and nested objects.

JSON input valid
Zod output

      
    

About this conversion

tRPC procedures use Zod natively — every .query and .mutation takes an .input(zod schema) and the inferred type flows through to the client without any code-generation step. The friction is bootstrapping the schema when you're rewriting an existing route as a tRPC procedure: you have JSON bodies your client already sends, but no schema yet. Paste the body and you get the .input() argument as a runnable z.object — with optional fields marked, nested filters as their own object, and array fields as z.array.

The sample on this page is a canonical cursor-paginated posts.list call: a userId, a limit, a cursor token, a filters object with optional sub-fields, and a sort discriminator. Drop the generated schema into your procedure's .input(), and the client gets full autocomplete on the input shape via tRPC's type inference. For mutations, paste the mutation argument JSON your client constructs — same rules: optional fields become .optional(), nullable fields union with z.null(), arrays of objects merge to a single item schema. The schema is also reusable on the client (form validation, query-key construction) since it's just a standard Zod object.

Same shape, other validators

Other JSON shapes