SQL to Prisma Seed Script Generator

Convert SQL INSERT statements into Prisma Client seed scripts (TypeScript) with createMany or individual create calls.

What is SQL to Prisma Seed Script Generator?

Prisma seed scripts populate your database with initial or test data using the Prisma Client API. Unlike raw SQL INSERT statements, Prisma seed scripts benefit from type checking, relation resolution, and the full Prisma Client feature set including create and createMany operations. This converter parses SQL INSERT statements — including multi-row inserts — and generates a complete seed.ts file with proper TypeScript syntax, camelCase field names following Prisma conventions, and a main() function wrapped in the standard Prisma seed pattern with error handling and graceful disconnection.

How to Use

  1. Toggle the Use createMany checkbox to batch multiple rows into a single createMany call for better performance, or disable it to generate individual create calls
  2. Paste your SQL INSERT statements into the input area — the parser handles single and multi-row INSERT syntax
  3. Click Generate to produce a complete seed.ts file with Prisma Client imports, the main function, and error handling
  4. Copy the output to prisma/seed.ts in your project and add the seed command to your package.json
  5. Run npx prisma db seed to execute the script against your database

Why Use This Tool?

Transforms raw SQL INSERT data into type-safe Prisma Client calls, eliminating manual translation of values and column names
createMany mode generates efficient batch inserts using a single SQL statement per table, significantly faster than individual create calls for large datasets
Column names are automatically converted from snake_case to camelCase to match Prisma model field naming conventions
SQL values are correctly typed in TypeScript: strings get proper escaping, numbers are unquoted, booleans become true/false, and NULL becomes null
The generated script follows the official Prisma seed pattern with try/catch error handling and prisma.$disconnect() in a finally block

Tips & Best Practices

  • Use createMany for seeding large lookup tables like countries, categories, or roles — it issues one INSERT statement instead of hundreds
  • Use individual create calls when you need Prisma to resolve relations or when each insert depends on the auto-generated ID of a previous one
  • Make sure your Prisma schema models match the table and column names in your SQL — the converter uses the table name to find the corresponding Prisma model
  • Add "seed": "ts-node prisma/seed.ts" to your package.json scripts section so Prisma can discover and run the seed file automatically

Frequently Asked Questions

How are SQL INSERT values converted to TypeScript?

The parser handles each SQL value type: quoted strings become TypeScript string literals with proper escaping, integers become number literals, decimals become number literals, TRUE/FALSE become boolean true/false, and NULL becomes null. Multi-row INSERT statements produce arrays of data objects for createMany or sequential create calls.

When should I avoid using createMany for seeding?

Avoid createMany when your seed data has relational dependencies — for example, if you need to insert a user first and then use the generated user ID in subsequent records. createMany also does not return the created records, so if you need to reference them later in the seed script, use individual create calls instead.

Is my data sent to a server?

No. All parsing and code generation runs entirely in your browser. Your SQL INSERT data never leaves your device, and no network requests are made during the conversion process.

How do I run the generated seed script?

Save the output as prisma/seed.ts, install ts-node as a dev dependency (pnpm add -D ts-node), add "seed": "ts-node prisma/seed.ts" to your package.json scripts, then run npx prisma db seed. Prisma will automatically execute the seed script against your configured database.

Can I seed data with relations?

The converter generates flat data objects from SQL INSERT statements. For relational data, you will need to manually adjust the generated script to use Prisma nested create syntax — for example, creating a post with its author in a single create call using the include or data.relation pattern.

Real-world Examples

Seeding a user table with createMany for performance

A development environment needs to seed a users table with 100 test accounts. Using createMany, all rows are inserted in a single database round-trip.

Input
INSERT INTO users (name, email, age) VALUES ('Alice', 'alice@example.com', 30);
INSERT INTO users (name, email, age) VALUES ('Bob', 'bob@example.com', 25);
Output
await prisma.user.createMany({
  data: [
    { name: 'Alice', email: 'alice@example.com', age: 30 },
    { name: 'Bob', email: 'bob@example.com', age: 25 }
  ],
});

Seeding related data with individual create calls

A blog needs to seed categories first, then posts that reference those categories. Individual create calls allow using the returned IDs for subsequent inserts.

Input
INSERT INTO categories (name) VALUES ('Technology');
INSERT INTO categories (name) VALUES ('Science');
Output
await prisma.category.create({
  data: { name: 'Technology' },
});
await prisma.category.create({
  data: { name: 'Science' },
});

Related Tools