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.
SQL → TypeScript Type Mapping
| SQL Type | TypeScript | Zod |
|---|---|---|
| VARCHAR, TEXT, CHAR | string | z.string() |
| INT, INTEGER, BIGINT, SERIAL | number | z.number() |
| BOOLEAN, BOOL | boolean | z.boolean() |
| TIMESTAMP, DATE, DATETIME | Date | z.string().datetime() |
| JSON, JSONB | unknown | z.unknown() |
| Other / Unknown | unknown | z.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.
Related Products
on GumroadDeveloper Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →DevPlaybook Interview Vault
210+ real technical interview questions with model answers, asked at Google, Meta, Amazon, Microsoft, Stripe, and Shopify. Covers Frontend (55), Backend (55), System Design (50), and DSA (50). Available in English and Traditional Chinese.
Buy on Gumroad →TypeScript Quick Reference Toolkit
5 practical reference files for TypeScript developers: cheatsheet, TS vs JS comparison, 20 utility types with real examples, tsconfig best practices template, and 15 common mistakes guide. Print it. Keep it on your desk.
Buy on Gumroad →You Might Also Need
SQL Formatter & Beautifier
Format and beautify SQL queries online. Auto-indent SELECT, FROM, WHERE, JOIN clauses, uppercase keywords, and minify SQL to a single line. Supports MySQL, PostgreSQL, SQLite. Free, runs in browser —
Open free tool →
Zod Schema Generator
Convert TypeScript interfaces and types to Zod schemas. Supports string, number, boolean, arrays, optional, nullable, and union types. Generates z.infer type export.
Open free tool →
SQL Query Formatter
Format and prettify SQL queries online. Auto-indent SELECT, FROM, WHERE, JOIN clauses, uppercase or lowercase keywords, configurable indent size. Supports MySQL, PostgreSQL, SQLite. Runs in browser.
Open free tool →
More Free Tools
Related Articles
Drizzle ORM Complete Guide: TypeScript Database Toolkit 2026
Master Drizzle ORM 2026: schema definition, migrations, relations, RLS support, and Drizzle Studio. See how it compares to Prisma for TypeScript projects.
Database Indexing Strategies Every Developer Must Know
Master database indexing in 2026. Learn B-tree, hash, composite, partial, and covering indexes with practical SQL examples for PostgreSQL and MySQL.
PostgreSQL vs MySQL: Which to Choose in 2026?
Comprehensive comparison of PostgreSQL and MySQL in 2026. Performance, JSON support, replication, licensing, and a decision framework for choosing the right database for your project.
PostgreSQL vs MySQL 2026: Which Database Should You Choose?
A comprehensive comparison of PostgreSQL and MySQL in 2026. Deep dive into performance, JSON support, replication, ecosystem, and which database fits your use case.
SQL Best Practices for Modern Development in 2026
Essential SQL best practices every developer should follow in 2026. Covers query optimization, indexing strategies, security patterns, and database design principles for PostgreSQL, MySQL, and SQLite.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$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.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →