Express Request Body to TypeScript

Paste the JSON body your Express POST endpoint receives and get a TypeScript interface you can plug into Request<P, ResBody, ReqBody>. Strongly typed req.body without `as` casts, in any Express 4 or 5 codebase.

JSON input valid
TypeScript output

      
    

About this conversion

Express routes type req.body as `any` by default — the framework can't know what your client posts, so the type gate falls open at the most important boundary. Augmenting Request with the generic Request<Params, ResBody, ReqBody> closes that gate, but only if you have a ReqBody type. Pasting a real request body (from a curl, a frontend's fetch, or your test fixtures) generates the interface directly, and from there every property access on req.body autocompletes correctly.

The sample on this page is a typical create-order POST body: a customerId, an items array of {productId, quantity, unitPrice}, a nested shippingAddress, an optional couponCode, and a notes string. Use the generated interface as ReqBody in your route handler signature — `(req: Request<{}, {}, OrderBody>, res) => ...` — and the editor pinpoints typos before they reach the runtime. TypeScript alone doesn't validate at runtime; pair this interface with the same-shape Zod sibling page (linked in the strip below) when you need a runtime parse on the route.

Same shape, other validators

Other JSON shapes