Skip to main content

SQL to TypeScript Types

Paste a SQL CREATE TABLE statement and instantly get a TypeScript interface and Zod validation schema. Handles common SQL types, NOT NULL constraints, and DEFAULT values. Supports PostgreSQL, MySQL, and SQLite dialects. Runs entirely in your browser.

✓ TypeScript interface output ✓ Zod z.object schema output ✓ NOT NULL → required vs optional ✓ Multiple tables at once
TypeScript + Zod Output

SQL → TypeScript Type Mapping

SQL Type TypeScript Zod
VARCHAR, TEXT, CHARstringz.string()
INT, INTEGER, BIGINT, SERIALnumberz.number()
BOOLEAN, BOOLbooleanz.boolean()
TIMESTAMP, DATE, DATETIMEDatez.string().datetime()
JSON, JSONBunknownz.unknown()
Other / Unknownunknownz.unknown()

Frequently Asked Questions

What SQL types are supported?▼

This tool handles the most common SQL column types: VARCHAR, TEXT, CHAR, and NVARCHAR map to string; INT, INTEGER, BIGINT, SMALLINT, TINYINT, SERIAL, BIGSERIAL, and NUMERIC/DECIMAL map to number; BOOLEAN and BOOL map to boolean; TIMESTAMP, DATETIME, DATE, and TIME map to Date in the TypeScript interface; JSON and JSONB map to unknown. Any unrecognized type also maps to unknown.

How does NOT NULL affect the TypeScript output?▼

Columns with NOT NULL constraint become required fields in the TypeScript interface (no ? optional modifier). Columns that allow NULL (no NOT NULL, or explicitly NULL) become optional fields with the type unioned with null, e.g. name?: string | null. This mirrors how database queries return nullable columns.

What is the Zod schema used for?▼

Zod is a TypeScript-first schema validation library. The generated z.object({...}) schema lets you validate API inputs, database query results, or form data at runtime. For example, you can use it in tRPC inputs, Next.js API routes, or Fastify request validation. The generated Zod schema mirrors the TypeScript interface — required fields use the base type and optional fields use .nullable().optional().

Can I paste multiple CREATE TABLE statements?▼

Yes. The parser handles multiple CREATE TABLE statements in one paste. Each table generates its own TypeScript interface and Zod schema block. The output blocks are separated by blank lines. Table names are converted to PascalCase for the interface name and camelCase for the Zod variable name.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

SQL Formatter & Beautifier Zod Schema Generator SQL Query Formatter SQL Query Formatter Pro SQL Index Advisor MySQL Query Explainer SQL Window Functions Builder Neon DB Query Builder JSON Schema Form Builder Prisma Schema Visualizer JSON Schema to Zod Converter Database Schema Diff Turso Edge DB Explorer AI SQL Builder — Pro Tool JSON Schema Generator JSON-LD Schema Generator Database Schema Visualizer Prisma Schema Builder LLM JSON Schema Builder TypeScript Discriminated Union Builder PostgreSQL Connection String Builder TypeScript Playground TypeScript to JavaScript Converter SQL ERD Diagram Generator TypeScript tsconfig.json Generator Drizzle Schema Generator Database Index Advisor OpenAI Function Calling Generator SQL JOIN Visualizer Database Query Cost Analyzer PlanetScale Branch Manager Code Tools JSON to TypeScript Interface Age Calculator Database Index Analyzer Zustand Store Builder GraphQL Client Configurator Axios Interceptor Builder Jest Mock Generator ESLint Config Generator Prettier Config Generator UUID v7 Generator Fake Data Generator GraphQL Query Builder Grafana Dashboard JSON Validator PostgreSQL EXPLAIN Analyzer OpenAPI Schema Validator GraphQL Fragment Generator Vitest Configuration Generator Jest Coverage Config Generator YAML Validator Pro GraphQL Schema Validator v2 AWS CDK Infrastructure as Code Guide Pulumi Modern IaC Guide OpenAPI Mock Generator Playwright Test Generator AI Agent Memory Planner RAG Chunking Calculator MCP Endpoint Tester Pulumi Stack Config Generator TanStack Query Config Builder SWR Config Generator Jotai Atom Explorer RAG Chunking Calculator Embedding Storage Calculator RAG Chunk Size Optimizer React Component Generator

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →