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
- 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
- Paste your SQL INSERT statements into the input area — the parser handles single and multi-row INSERT syntax
- Click Generate to produce a complete seed.ts file with Prisma Client imports, the main function, and error handling
- Copy the output to prisma/seed.ts in your project and add the seed command to your package.json
- Run npx prisma db seed to execute the script against your database
Why Use This Tool?
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.
INSERT INTO users (name, email, age) VALUES ('Alice', '[email protected]', 30);
INSERT INTO users (name, email, age) VALUES ('Bob', '[email protected]', 25);await prisma.user.createMany({
data: [
{ name: 'Alice', email: '[email protected]', age: 30 },
{ name: 'Bob', email: '[email protected]', 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.
INSERT INTO categories (name) VALUES ('Technology');
INSERT INTO categories (name) VALUES ('Science');await prisma.category.create({
data: { name: 'Technology' },
});
await prisma.category.create({
data: { name: 'Science' },
});