Skip to content
Free tool · runs in your browser

Postgres to TypeScript type generator

Paste your Supabase or Postgres schema and get typed interfaces or Zod schemas, with the right nullability and array handling. No install, no account, nothing uploaded.

Postgres DDLexample shown
export interface Profiles {
  id: string;
  username: string;
  bio: string | null;
  followers: number;
  is_verified: boolean;
  settings: unknown | null;
  created_at: string;
}
  • profiles.id references "users", which isn't in the pasted DDL.

Generate TypeScript types from a Postgres schema

Keeping your TypeScript types in sync with your database is tedious work that is easy to get subtly wrong. A column is nullable but the type says it is not, an array comes back as a string, a timestamp is typed as a Date when the API actually returns a string. This tool takes that guesswork away. Paste your CREATE TABLE statements and it writes an interface for each table, with every column mapped to the type it really has.

It reads the same DDL that our schema visualizer uses, so you can diagram a schema and type it from the exact same paste. Switch between plain TypeScript interfaces and Zod schemas with one click, and copy the result straight into your project.

How the types are mapped

  • uuid, text, varchar, and the character types become string.
  • int, bigint, numeric, and the floating types become number.
  • boolean becomes boolean, and timestamptz, date, and time become string, matching what the REST API returns.
  • jsonb becomes unknown so you narrow it deliberately, and an array type like text[] becomes string[].
  • Nullable columns get a | null in TypeScript or a .nullable() in Zod, so the types tell the truth about what can be missing.

TypeScript interfaces or Zod schemas

TypeScript interfaces are what you want for typing query results and props. Zod schemas go a step further: they validate data at runtime, which is exactly what you need when the data crosses a boundary you do not control, like a webhook body, a form submission, or an API response. The Zod output includes an inferred type for each table with z.infer, so you get both the validator and the static type from one definition.

Where types stop and the workspace begins

Typed rows make your code safer to write. Working with the rows themselves is the next step. A Suparbase account connects to a Supabase project and gives you type-aware editing, foreign-key lookups, filtering, and bulk operations through an encrypted server-side proxy, so your API key never reaches the browser. Generate the types here, then operate on the data there.

Frequently asked questions

How does it decide if a field can be null?
A column marked NOT NULL, or one that is part of the primary key, becomes a required non-null field. Every other column is treated as nullable, so its type gets a null option in TypeScript and a .nullable() in Zod. That matches how a row actually comes back from the database.
What does it do with jsonb columns?
A json or jsonb column becomes unknown in TypeScript and z.unknown() in Zod, because the shape is not described in the schema. Narrow it yourself where you read it, or replace unknown with a specific interface once you know the payload.
Does it handle arrays and custom types?
Yes for arrays: a text[] column becomes string[], and the Zod output wraps the element validator in z.array. Types it does not recognise, including enums and custom domains, fall back to unknown so the output still compiles. You can swap those for a union or a specific type by hand.
Is this the same as supabase gen types?
It covers the same need, generate types from your schema, but it works from pasted DDL instead of a live connection or the CLI. That makes it handy for a quick one-off, a schema you are still drafting, or a table you copied from a migration. For a full generated Database type across every table, the Supabase CLI is still the tool to reach for.
Is my schema sent anywhere?
No. Parsing and code generation run entirely in your browser. The DDL you paste is never uploaded or stored, so it is safe to use with a production schema.

Types are step one. Operating on the data is step two.

Connect a Supabase project to Suparbase for a full admin workspace, with type-aware editing and an encrypted server-side proxy that keeps your key off the client.