Schemint

paste PostgreSQL or JSON, get your schema reviewed like a senior would

PostgreSQL CREATE TABLE to Zod schema

Paste a CREATE TABLE, get a Zod schema. Nothing you paste is stored.

Paste a PostgreSQL CREATE TABLE and get a Zod schema that validates what the database will actually accept: VARCHAR(n) becomes z.string().max(n), UUID becomes z.string().uuid(), integer columns get .int(), and nullable columns get .nullable(). The inferred TypeScript type comes along via z.infer.

Mapped from your real DDL, on the server, discarded after the response.

Try it on your own schema

Example

PostgreSQL in:

CREATE TABLE product (
    id BIGSERIAL PRIMARY KEY,
    sku VARCHAR(40) UNIQUE NOT NULL,
    name VARCHAR(200) NOT NULL,
    price NUMERIC(12, 2) NOT NULL,
    in_stock BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMP NOT NULL DEFAULT now()
);

Generated:

ProductSchema.ts

import { z } from "zod";

export const ProductSchema = z.object({
  id: z.number().int(),
  sku: z.string().max(40),
  name: z.string().max(200),
  price: z.number(),
  inStock: z.boolean(),
  createdAt: z.string(),
});

export type Product = z.infer<typeof ProductSchema>;

Related