SQL to Drizzle ORM Schema Converter
Paste any CREATE TABLE SQL and get a Drizzle schema.ts with pgTable definitions, pgEnum, relations, and deduplicated drizzle-orm/pg-core imports.
Runs 100% in your browser. Your input and files never leave your device.
Why use our online SQL to Drizzle ORM Schema Converter?
Drizzle ORM uses TypeScript-native table definitions — each column is a function call from drizzle-orm/pg-core. Translating a 20-column SQL table manually means looking up the right function for each type, chaining .notNull() and .default() correctly, and writing the relations() block for every foreign key. This tool automates all of that.
How to use SQL to Drizzle ORM Schema Converter
- 1Paste your SQL
Paste one or more CREATE TABLE statements. Click the Drizzle tab in the toolbar.
- 2Review the output
The right panel shows a complete schema.ts with imports, pgEnum definitions, pgTable definitions, and relations blocks.
- 3Check the type mapping
Expand the Type Mapping panel to verify every column — SQL type → Drizzle function with correct args.
- 4Copy or download
Click Copy to grab schema.ts, or Download ZIP for the full output.
Frequently Asked Questions
Which drizzle-orm/pg-core functions are used for which SQL types?
VARCHAR(n) → varchar("col", { length: n }), TIMESTAMPTZ → timestamp("col", { withTimezone: true }), JSONB → jsonb("col"), INTEGER → integer("col"), BIGINT → bigint("col", { mode: "number" }), SERIAL → serial("col"), UUID → uuid("col"). Array types chain .array().
How are relations generated in Drizzle output?
Each foreign key generates a relations() block using the drizzle-orm relations helper. The owning side gets a one() relation referencing the parent table. The fields and references arrays are inferred from the FK column names.
What Drizzle version is the output targeting?
Drizzle ORM 0.39+ (drizzle-orm package). The output uses the pgTable and relations API which is stable across 0.30+.
Are enums supported?
Yes. CREATE TYPE name AS ENUM (...) generates a pgEnum("name", [...]) call and the correct column type in each table that references it.
How is BYTEA handled in Drizzle?
BYTEA has no built-in function in drizzle-orm/pg-core yet. The converter uses customType and emits a warning with a note to implement the custom type according to the Drizzle docs.
Related Tools
More Developer Tools- JSON FormatterClean, minify, and validate JSON data structures.Free • In browser
- SQL FormatterFormat, beautify, and minify SQL queries online. Supports MySQL, PostgreSQL, SQLite, and more SQL dialects.Free • In browser
- Regex TesterReal-time expression matching and testing.Free • In browser
Also useful: Cron BuilderMermaid Live Editor