Prisma Repository Code Generator

A tool that generates a repository interface, a PrismaClient-based implementation class, and an Express controller usage example (dependency injection pattern) from a pasted schema.prisma model, right in your browser. You can toggle the class naming style, async/await usage, and explicit return types.

Your schema is processed entirely in your browser and is never sent to an external server.
Generation options
Class naming style

How to use

  1. Paste a schema.prisma model definition into the input field. You can also try it out with "Load sample model".
  2. If multiple models are found, choose the one to generate code for from the "Target model" dropdown.
  3. Use "Generation options" to toggle the class naming style (I-prefix or Interface-suffix), whether to use async/await, and whether to include explicit return types.
  4. Switch between the "① Repository interface", "② PrismaClient implementation", and "③ Express usage example" tabs to review and copy each piece of code.

About this tool

The Prisma Repository Code Generator automatically generates a full set of repository-pattern code — commonly used in the data access layer — from a model definition written in schema.prisma. It saves you the manual work of writing CRUD logic every time you add a new model, and helps teams keep their coding conventions consistent.

The generated interface and implementation use Prisma's own generated types, such as `Prisma.XxxCreateInput` and `Prisma.XxxUpdateInput`, directly. This makes it easy to keep up with schema changes and drop the generated code straight into a real project. PrismaClient is injected through the constructor (a dependency injection pattern), so it can be swapped for a mock implementation in tests.

The model's primary key (a field marked `@id`, or a field named `id` if none is marked) is detected automatically and used for the argument types of `findUnique`, `update`, and `delete`. In the Express controller example, the repository is passed as an argument to a router factory function, making it easy to swap in a mock repository for unit tests.

Frequently asked questions

Can I use the generated code directly in my project?

Yes, as long as your project has already generated `@prisma/client` and has the model's types available (e.g. `User`, `Prisma.UserCreateInput`), you can paste the code in directly. Adjust file names and directory structure as needed for your project.

Can I generate code for multiple models at once?

You can paste multiple model definitions into the input field, but code is generated for one model at a time. If multiple models are detected, switch between them using the "Target model" dropdown.

How are relation fields (references to other models) handled?

Since the generated `create` and `update` method arguments use Prisma's own generated `Prisma.XxxCreateInput` and `Prisma.XxxUpdateInput` types directly, creating and updating nested relations is supported at the type level too — there's no need to manually assemble individual fields.

Is my input schema sent to a server?

No. Parsing the schema and generating code both happen entirely with JavaScript in your browser.