Paste your CREATE TABLE statements and get a Zod object schema per table, plus a z.infer'd TypeScript type — ready to drop into request validation.
// Generated by ERD Factory - review relation/field names before use.
import { z } from "zod";
export const usersSchema = z.object({
id: z.number(),
email: z.string(),
full_name: z.string().nullable(),
created_at: z.string().nullable(),
last_login_at: z.string().nullable(),
});
export type Users = z.infer<typeof usersSchema>;
export const ordersSchema = z.object({
id: z.number(),
user_id: z.number().nullable(),
status: z.string(),
total_cents: z.number(),
currency: z.string().nullable(),
placed_at: z.string().nullable(),
shipped_at: z.string().nullable(),
});
export type Orders = z.infer<typeof ordersSchema>;
export const orderItemsSchema = z.object({
id: z.number(),
order_id: z.number().nullable(),
product_id: z.number(),
quantity: z.number(),
});
export type OrderItems = z.infer<typeof orderItemsSchema>;
export const productsSchema = z.object({
id: z.number(),
sku: z.string(),
name: z.string(),
price_cents: z.number(),
inventory_count: z.number().nullable(),
active: z.boolean().nullable(),
});
export type Products = z.infer<typeof productsSchema>;
export const paymentsSchema = z.object({
id: z.number(),
order_id: z.number().nullable(),
amount_cents: z.number(),
method: z.string(),
processed_at: z.string().nullable(),
});
export type Payments = z.infer<typeof paymentsSchema>;
export const sessionsSchema = z.object({
id: z.number(),
token: z.string(),
expires_at: z.string().nullable(),
});
export type Sessions = z.infer<typeof sessionsSchema>;
See these 6 tables as an interactive diagram, get AI-suggested fixes, and save your schema — free.
Open in the full editorPaste a schema and see your first analysis in under ten seconds.
Schema visualization & analysis for people who ship databases.