npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

prisma-standalone-types

v1.0.0

Published

Generate standalone TypeScript interfaces from Prisma schema via JSON Schema

Readme

Prisma Standalone Types

Generate standalone TypeScript interfaces from your Prisma schema that can be copied to any project without dependencies.

🎯 Why This Package?

  • Zero Dependencies: Generated types have no runtime dependencies
  • Copy Anywhere: Share types between projects, microservices, or frontends
  • Always Up-to-Date: Generate fresh types whenever your schema changes
  • Full Type Safety: Includes enums, nullable types, and proper Date handling

🚀 Quick Start

Installation

# Install as dev dependency
npm install --save-dev prisma-standalone-types
# or
pnpm add -D prisma-standalone-types
# or 
yarn add -D prisma-standalone-types

Prerequisites

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

generator client {
  provider = "prisma-client-js"
}

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

// Your models here...
model User {
  id    String @id @default(uuid())
  name  String
  email String @unique
}

Basic Usage

# Generate standalone types from your Prisma schema
npx prisma-standalone-types

# Specify custom output location
npx prisma-standalone-types --output lib/types.ts

# Use custom schema location
npx prisma-standalone-types --schema custom/schema.prisma --output types.ts

📖 How It Works

graph LR
    A[Prisma Schema] --> B[prisma generate]
    B --> C[JSON Schema]
    C --> D[TypeScript Interfaces]
    D --> E[Copy to Any Project! 🎉]
  1. Reads your Prisma schema (prisma/schema.prisma)
  2. Generates JSON Schema using prisma-json-schema-generator
  3. Converts to TypeScript with proper type mappings
  4. Outputs clean interfaces with zero dependencies

📋 Example Output

Input 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 TypeScript:

// Generated standalone TypeScript interfaces from Prisma schema
// This file has no dependencies and can be copied to any project

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

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

🔧 CLI Options

| Option | Short | Description | Default | |--------|-------|-------------|---------| | --schema | -s | Prisma schema file path | prisma/schema.prisma | | --input | -i | JSON schema file (if already generated) | - | | --output | -o | Output TypeScript file | types/standalone.ts | | --relations | -r | Include relation types (experimental) | false | | --help | -h | Show help | - |

📚 Usage Examples

Generate Types for Different Environments

# Development types
npx prisma-standalone-types --output src/types/database.ts

# Production API types  
npx prisma-standalone-types --output dist/types.ts

# Frontend shared types
npx prisma-standalone-types --output ../frontend/src/types/api.ts

Package.json Scripts

Add to your package.json:

{
  "scripts": {
    "db:generate": "prisma generate",
    "types:generate": "prisma-standalone-types --output src/types/database.ts",
    "db:types": "npm run db:generate && npm run types:generate"
  }
}

Programmatic Usage

import { generateStandaloneTypes } from 'prisma-standalone-types';

await generateStandaloneTypes({
  prismaSchema: 'prisma/schema.prisma',
  output: 'src/types/database.ts',
  includeRelations: false
});

🔄 Integration with CI/CD

GitHub Actions

name: Generate Types
on: 
  push:
    paths: ['prisma/schema.prisma']

jobs:
  generate-types:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18
      - run: npm ci
      - run: npx prisma-standalone-types --output types/database.ts
      - run: git add types/database.ts
      - run: git commit -m "Update generated types" || exit 0
      - run: git push

🏗️ Project Structure

After running the generator:

your-project/
├── prisma/
│   └── schema.prisma
├── types/
│   ├── json-schema.json      # Auto-generated by Prisma
│   └── standalone.ts         # 🎯 Your standalone types!
└── package.json

🔍 Type Mappings

| Prisma Type | TypeScript Type | |-------------|-----------------| | String | string | | Int | number | | Float | number | | Boolean | boolean | | DateTime | Date | | String? | string \| null | | MyEnum | MyEnum | | MyModel[] | MyModel[] |

🚨 Limitations

  • Relations: Circular references are skipped by default (use --relations experimentally)
  • Complex Types: Some advanced Prisma features may not be fully supported
  • Custom Types: Unsupported types default to any

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

MIT License - see LICENSE file for details.

🙋 Support

🔗 Related Packages


Made with ❤️ for the Prisma community