💙 Supporting healthcare non-profits: Metadataloop is free for 6–12 months. Contact Us to get started.
Free Online Tool

SQL to TypeScript Interface Generator

Paste a CREATE TABLE statement, get a ready-to-use TypeScript interface.

Open the SQL → TypeScript Generator →

Overview

Keeping frontend types in sync with a database schema is tedious by hand. MetaDataLoop's SQL-to-types tool parses your CREATE TABLE statement and emits a TypeScript interface per table — numeric columns become number, booleans become boolean, and nullable columns are marked optional and unioned with null.

What you get

✓ INCLUDED
One interface per CREATE TABLE statement, multi-table paste supported
✓ INCLUDED
Automatic camelCase conversion for snake_case column names
✓ INCLUDED
Nullable columns mapped to optional + | null fields
✓ INCLUDED
Also available as JSON Schema (draft-07) output for validation libraries
✓ INCLUDED
Free, no signup, nothing stored server-side

Type detection reference

Sample values and the dialect-native type they map to.

Sample valueInferred type
INT, BIGINT, SERIALnumber
DECIMAL, NUMERIC, FLOATnumber
BOOLEAN, BITboolean
VARCHAR, TEXT, DATE, UUIDstring
JSON, JSONBRecord<string, unknown>
nullable columnfield?: type | null

Example

Input
CREATE TABLE users (
  id UUID PRIMARY KEY,
  email VARCHAR(255) NOT NULL,
  full_name VARCHAR(120),
  created_at TIMESTAMP NOT NULL
);
Output
export interface Users {
  id: string;
  email: string;
  fullName?: string | null;
  createdAt: string;
}

Frequently asked questions

Can it generate JSON Schema instead?
Yes — switch the output format toggle on the tool page to get a draft-07 JSON Schema document instead of TypeScript.
Does it handle multiple tables in one paste?
Yes — every CREATE TABLE statement in your input is parsed and emitted as its own interface.
What about foreign key relations?
FK columns are typed like any other column (usually number or string) — nested relation types aren't generated automatically.

Try it now

No signup, no install — runs entirely in your browser.

Open the SQL → TypeScript Generator →

⚠ Confirm Delete