Free Online SQL to TypeScript, Prisma & Zod Schema Converter
SQL to TypeScript, Prisma & Zod Converter
Convert CREATE TABLE SQL into TypeScript, Prisma, Zod and JSON Schema * 100% free * No upload
About This Free Online SQL to TypeScript Converter
Copying column names by hand out of a 40-line migration file gets old fast. This free online SQL to TypeScript converter reads your CREATE TABLE statements and turns them into TypeScript interfaces, Prisma models, Zod schemas, or JSON Schema right away. It handles PostgreSQL, MySQL, and SQLite column types, spots NOT NULL and PRIMARY KEY constraints, and optionally converts snake_case columns into camelCase. Everything runs inside your browser tab, so private database schemas never hit an external server.
How This Converter Parses SQL
The parser extracts each CREATE TABLE block, splits the column definitions cleanly even when types have parentheses like DECIMAL(10, 2), and ignores table-level constraints like FOREIGN KEY or INDEX lines. Then it maps each SQL type and nullability flag to the target format you chose.
How to Use It
- Paste one or more
CREATE TABLEstatements into the left box. - Pick TypeScript, Prisma, Zod, or JSON Schema from the Output Format menu.
- Toggle camelCase conversion or optional nullable fields if your API layer expects them.
- Copy the generated code or download it directly as a
.ts,.prisma, or.jsonfile.
Tips for Cleaner Type Output
- If your JSON API serializes timestamps as ISO strings instead of
Dateobjects, uncheck the Date mapping option so TypeScript outputsstring. - You can paste multiple
CREATE TABLEblocks in a single run; the tool loops through all of them in order. - For Prisma models, double-check relation fields after pasting, since foreign keys vary depending on how you name your relations.
Frequently Asked Questions
Which SQL dialects work with this tool?
Standard CREATE TABLE syntax from PostgreSQL, MySQL, MariaDB, and SQLite all parse cleanly, including backticks and double-quoted identifiers.
Does it handle DECIMAL(10, 2) or VARCHAR(255)?
Yes. The column splitter tracks parentheses depth, so commas inside precision arguments won't break the column list.
How are NOT NULL and nullable columns treated?
Columns without NOT NULL (unless marked PRIMARY KEY) are treated as optional or nullable when that option is checked.
Is my database schema uploaded anywhere?
No. All SQL parsing and code generation happens locally in JavaScript inside your browser.
Can I convert multiple tables at once?
Yes. Paste as many CREATE TABLE statements as you need into the input box and they'll all appear in the output.
Comments
Post a Comment