Introducing Prisma Standalone Types: Copy Your Database Types Anywhere

Generate clean, dependency-free TypeScript interfaces from your Prisma schema

·Matija Žiberna·
Introducing Prisma Standalone Types: Copy Your Database Types Anywhere

📚 Get Practical Development Guides

Join developers getting comprehensive guides, code examples, optimization tips, and time-saving prompts to accelerate their development workflow.

No spam. Unsubscribe anytime.

I had a problem. I was working with Prisma across multiple projects and needed to share database types between them. The regular Prisma client comes with all its dependencies and runtime overhead. What I really wanted was just the clean TypeScript interfaces I could copy anywhere.

The Problem

When you use Prisma, you get fantastic type safety. But those types are tied to the Prisma client. If you want to use the same types in:

  • Your frontend React app
  • A separate microservice
  • A shared utility library
  • Another project entirely

You're stuck. You either duplicate type definitions manually or import the entire Prisma client just for types. Neither solution felt right.

The Solution

I built prisma-standalone-types. It generates clean TypeScript interfaces from your Prisma schema with zero dependencies. You can copy these types anywhere and they just work.

Here's what it does:

  1. Reads your existing Prisma schema
  2. Generates JSON Schema using prisma-json-schema-generator
  3. Converts that to clean TypeScript interfaces
  4. Outputs a file you can copy to any project

Example

Your Prisma schema:

enum UserRole {
  ADMIN
  USER
}

model User {
  id        String   @id @default(uuid())
  name      String
  email     String?
  role      UserRole @default(USER)
  createdAt DateTime @default(now())
}

Generated output:

export enum UserRole {
  ADMIN = 'ADMIN',
  USER = 'USER',
}

export interface User {
  id: string;
  name: string;
  email?: string | null;
  role: UserRole;
  createdAt: Date;
}

Perfect. Clean. No dependencies.

How to Use It

Install the package:

npm install --save-dev prisma-standalone-types

Make sure your prisma/schema.prisma includes the JSON schema generator:

generator jsonSchema {
  provider = "prisma-json-schema-generator"
  output   = "../types"
}

Generate your types:

npx prisma-standalone-types --output types/database.ts

That's it. Copy the generated file anywhere you need those types.

Why This Matters

Type safety shouldn't stop at project boundaries. With standalone types, you can:

  • Share types between frontend and backend
  • Use the same types in multiple microservices
  • Keep types in sync across your entire stack
  • Avoid runtime dependencies when you just need types

The generated files are completely self contained. No imports, no dependencies, just pure TypeScript interfaces you can use anywhere.

Get Started

The package is available on npm and the source code is on GitHub.

Links:

I built this because I needed it. Hopefully it solves the same problem for you. The package handles all the complex JSON Schema to TypeScript conversion automatically. You just run one command and get clean, copyable types.

Try it out and let me know what you think. Issues and contributions welcome on GitHub.


Built with ❤️ for the Prisma community

3

Comments

Leave a Comment

Your email will not be published

10-2000 characters

• Comments are automatically approved and will appear immediately

• Your name and email will be saved for future comments

• Be respectful and constructive in your feedback

• No spam, self-promotion, or off-topic content

Matija Žiberna
Matija Žiberna
Full-stack developer, co-founder

I'm Matija Žiberna, a self-taught full-stack developer and co-founder passionate about building products, writing clean code, and figuring out how to turn ideas into businesses. I write about web development with Next.js, lessons from entrepreneurship, and the journey of learning by doing. My goal is to provide value through code—whether it's through tools, content, or real-world software.

You might be interested in