Schema Generator Knowledge Base

JSON to Drizzle ORM: Generate pgTable, mysqlTable & sqliteTable

Generate Drizzle ORM table definitions from JSON for PostgreSQL, MySQL, and SQLite. Correct column types, import statements, and primaryKey annotations. Free.

What is Drizzle ORM?

Drizzle ORM is a lightweight, TypeScript-native ORM for PostgreSQL, MySQL, and SQLite. Unlike Prisma, schemas are defined in TypeScript code using builder functions (pgTable, mysqlTable, sqliteTable), giving full type inference without a separate schema file.

Why Generate from JSON?

When building API-backed applications, you often have sample JSON from an existing API or database. Generating a Drizzle schema from that sample saves 10–20 minutes of manual mapping per table.

Column Type Mapping per Dialect

  • PostgreSQL: text(), integer(), doublePrecision(), boolean(), timestamp()
  • MySQL: varchar(), int(), double(), tinyint(), datetime()
  • SQLite: text(), integer(), real(), integer() (bool), text() (date)
json
// JSON Input
{ "id": 1, "email": "a@example.com", "score": 9.5, "active": true }

// Generated Drizzle Schema (PostgreSQL)
import { pgTable, integer, text, doublePrecision, boolean } from 'drizzle-orm/pg-core';

export const users = pgTable('users', {
  id:     integer('id').primaryKey().notNull(),
  email:  text('email').notNull(),
  score:  doublePrecision('score').notNull(),
  active: boolean('active').notNull(),
});

Try the free JSON to Drizzle

Runs entirely in your browser — no upload, no signup, and your data never leaves your device.

Open JSON to Drizzle

Frequently Asked Questions

Does the output include the import statement?

Yes. The generated code includes the correct import from drizzle-orm/pg-core, drizzle-orm/mysql-core, or drizzle-orm/sqlite-core.

How do I switch between PostgreSQL, MySQL, and SQLite?

Use the Dialect dropdown in the toolbar. The column functions and import path update automatically.

Can I use the output directly in my project?

Yes. The output is a complete TypeScript module you can paste directly into a new file in your Drizzle project.

Tools mentioned in this guide

Related JSON Topics & Reference Articles