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-normalize

v0.1.1

Published

Rewrite snake_case identifiers in Prisma schema files to PascalCase/camelCase while preserving the original DB names via @map / @@map.

Readme

prisma-normalize

Rewrite snake_case identifiers in Prisma schema files to PascalCase / camelCase while preserving the original database names via @map and @@map.

Useful after prisma db pull against a snake_case database when you want idiomatic camelCase TypeScript without touching the schema by hand.

Install

npm install -D prisma-normalize

Use

# walk a directory for .prisma files and rewrite in place
prisma-normalize ./prisma

# or a specific file
prisma-normalize ./prisma/schema.prisma

# CI mode: don't write, exit 1 if anything would change
prisma-normalize --check ./prisma

# print what would change without writing
prisma-normalize --dry-run ./prisma

Wire into your workflow:

{
  "scripts": {
    "prisma:pull": "prisma db pull && prisma-normalize ./prisma && prisma format",
    "lint:prisma": "prisma-normalize --check ./prisma"
  }
}

What it does

Given:

model blog_post {
  id          Int      @id @default(autoincrement())
  author_id   Int
  created_at  DateTime @default(now())
  title       String   @db.VarChar(255)
  author      user     @relation(fields: [author_id], references: [id])

  @@index([author_id])
}

It produces:

model BlogPost {
  id        Int      @id @default(autoincrement())
  authorId  Int      @map("author_id")
  createdAt DateTime @default(now()) @map("created_at")
  title     String   @db.VarChar(255)
  author    User     @relation(fields: [authorId], references: [id])

  @@index([authorId])
  @@map("blog_post")
}

The database schema is untouched — Prisma translates camelCase ↔ snake_case at query time.

Rules

  • model / view / enum names in snake_case → PascalCase, with @@map("original_name") appended.
  • Scalar field names in snake_case → camelCase, with @map("original_name") appended.
  • Relation field names → camelCase, no @map (relations are not DB columns).
  • Field type references update to the renamed type.
  • @relation(fields: [...]), @@index([...]), @@unique([...]), @@id([...]) field lists update to the renamed field names.
  • Already-normalized blocks are left alone — the transform is idempotent.
  • Constraint names inside attributes (@id(map: "pk_…"), @@index([…], map: "idx_…")) are preserved untouched.

Multiple files

When you pass a directory, the CLI does a two-pass walk: first it scans every .prisma file to learn all model/enum/view names, then it transforms each file using that shared map. This is what makes cross-file type references rename correctly — e.g. a user relation field in post.prisma becomes User because model user was discovered in user.prisma.

After running, you'll usually want to chain prisma format to tidy column alignment:

prisma-normalize ./prisma && prisma format

Library API

import { normalizeSchema, buildTypeMap } from 'prisma-normalize'

// Single file — local typeMap built automatically:
const { output, changed } = normalizeSchema(schemaText)

// Multiple files sharing a typeMap (recommended for projects split across files):
const typeMap = buildTypeMap(allFileContents)
for (const content of allFileContents) {
  const { output } = normalizeSchema(content, typeMap)
  // write output back...
}

License

MIT