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

SQL → JSON Schema / TypeScript Interface Generator

Paste one or more CREATE TABLE statements — get a JSON Schema document or TypeScript interface declarations, with nullable columns mapped to optional/nullable fields automatically.

Output
Input · CREATE TABLE SQL
Output
// Output will appear here.

Generate TypeScript interfaces or JSON Schema from SQL

Keeping frontend types and API contracts in sync with your database schema is tedious to do by hand. Paste your CREATE TABLE statements and this tool emits either a TypeScript interface per table or a JSON Schema document — ready to drop into a shared types package or API validation layer.

Type mapping rules

  • Integers / serials → number (TS) or integer (JSON Schema).
  • Decimal / float / numeric → number.
  • Boolean / bit → boolean.
  • UUID → string with format: "uuid" in JSON Schema.
  • Timestamp / datetime → string with format: "date-time".
  • Date → string with format: "date".
  • Nullable columns → optional (field?:) and unioned with null in TypeScript; omitted from required in JSON Schema.

Example

CREATE TABLE users (
  id UUID PRIMARY KEY,
  email VARCHAR(255) NOT NULL,
  full_name VARCHAR(120),
  created_at TIMESTAMP NOT NULL
);

TypeScript output:

export interface Users {
  id: string;
  email: string;
  fullName?: string | null;
  createdAt: string;
}

Common use cases

Frontend type safety

Keep React/Vue/Angular models aligned with the backend schema without manual edits.

API contract validation

Use the JSON Schema output with ajv, Zod-compatible tooling, or OpenAPI definitions.

Monorepo shared types

Generate a types package once and share it across backend and frontend.

Documentation

JSON Schema doubles as machine-readable documentation for every table.

FAQ

Does it support multiple tables in one paste? Yes — every CREATE TABLE statement in the input is parsed and emitted as its own interface or schema.

What happens to foreign keys? They're mapped like any other column by type; relation-aware nested types aren't generated automatically — add those by hand if needed.

Is my SQL stored anywhere? No. It's parsed in-memory for the single request and discarded.

⚠ Confirm Delete