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

@tomochandv/prisma-camel

v1.0.7

Published

Convert Prisma schema snake_case to camelCase

Readme

🐫 prisma-camel

Automatically convert snake_case to camelCase in your Prisma schema files

English | 한국어


✨ Features

  • 🔄 Model Names: model user_profilemodel userProfile
  • 📝 Field Names: user_name StringuserName String @map("user_name")
  • 🎯 Type & Enum: Converts enum user_roleenum userRole
  • 💾 Database Compatible: Automatically adds @map() attributes to maintain DB compatibility
  • Prisma 7.0+ Support: Preserves generator/datasource configurations
  • 🎨 Zero Config: Works out of the box

📦 Installation

Global Installation

npm install -g @tomochandv/prisma-camel

Project Installation (Recommended)

npm install -D @tomochandv/prisma-camel

Or use with npx (No installation)

npx @tomochandv/prisma-camel

🚀 Usage

CLI Commands

# Convert and overwrite original file
prisma-camel schema.prisma

# Convert and save to new file
prisma-camel schema.prisma schema-camel.prisma

# Using npx
npx @tomochandv/prisma-camel schema.prisma

# With npm scripts (after installing as dev dependency)
npm run prisma-camel schema.prisma

Add to package.json scripts

{
  "scripts": {
    "convert-schema": "prisma-camel prisma/schema.prisma"
  }
}

Then run:

npm run convert-schema

Programmatic Usage

import { convertPrismaSchema } from '@tomochandv/prisma-camel'

const schema = `
model user_profile {
  id         Int    @id @default(autoincrement())
  user_name  String
  created_at DateTime @default(now())
}
`

const converted = convertPrismaSchema(schema)
console.log(converted)

📖 Example

Before

generator client {
  provider = "prisma-client"
  output   = "../src/generated/prisma"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model user_profile {
  id              Int      @id @default(autoincrement())
  user_name       String
  email_address   String   @unique
  created_at      DateTime @default(now())
  updated_at      DateTime @updatedAt

  posts           blog_post[]
}

model blog_post {
  id              Int      @id @default(autoincrement())
  post_title      String
  post_content    String
  author_id       Int

  author          user_profile @relation(fields: [author_id], references: [id])
}

enum user_role {
  ADMIN
  USER
  GUEST
}

After

generator client {
  provider = "prisma-client"
  output   = "../src/generated/prisma"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model userProfile {
  id              Int      @id @default(autoincrement())
  userName        String   @map("user_name")
  emailAddress    String   @unique @map("email_address")
  createdAt       DateTime @default(now()) @map("created_at")
  updatedAt       DateTime @updatedAt @map("updated_at")

  posts           blogPost[]
}

model blogPost {
  id              Int      @id @default(autoincrement())
  postTitle       String   @map("post_title")
  postContent     String   @map("post_content")
  authorId        Int      @map("author_id")

  author          userProfile @relation(fields: [authorId], references: [id])
}

enum userRole {
  ADMIN
  USER
  GUEST
}

🎯 Key Features

1. Database Compatibility

The tool automatically adds @map() attributes to preserve your database column names:

// Your database still uses snake_case
userName String @map("user_name")

2. Safe Conversion

  • Only converts valid snake_case patterns
  • Preserves existing @map() attributes
  • Maintains comments and formatting
  • Keeps generator/datasource blocks unchanged

3. Type Reference Updates

Automatically updates model references in relations:

author user_profile @relation(...)  // Before
author userProfile @relation(...)   // After

📚 API

convertPrismaSchema(schema: string): string

Converts a Prisma schema string from snake_case to camelCase.

toCamelCase(str: string): string

Converts a snake_case string to camelCase.

isSnakeCase(str: string): boolean

Checks if a string is in snake_case format.

🛠 Development

# Install dependencies
npm install

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Lint
npm run lint

# Format code
npm run format

# Build
npm run build

📄 License

MIT © tomochandv

🤝 Contributing

Issues and pull requests are always welcome!

🔗 Links


🐫 prisma-camel

Prisma 스키마 파일의 snake_case를 camelCase로 자동 변환

✨ 기능

  • 🔄 모델 이름 변환: model user_profilemodel userProfile
  • 📝 필드 이름 변환: user_name StringuserName String @map("user_name")
  • 🎯 타입 & Enum: enum user_roleenum userRole
  • 💾 데이터베이스 호환성: @map() 속성 자동 추가로 DB와 호환성 유지
  • Prisma 7.0+ 지원: generator/datasource 설정 보존
  • 🎨 별도 설정 불필요: 바로 사용 가능

📦 설치

전역 설치

npm install -g @tomochandv/prisma-camel

프로젝트 설치 (권장)

npm install -D @tomochandv/prisma-camel

npx로 설치 없이 사용

npx @tomochandv/prisma-camel

🚀 사용법

CLI 명령어

# 원본 파일 덮어쓰기
prisma-camel schema.prisma

# 새 파일로 저장
prisma-camel schema.prisma schema-camel.prisma

# npx 사용
npx @tomochandv/prisma-camel schema.prisma

# npm scripts 사용 (dev dependency로 설치 후)
npm run prisma-camel schema.prisma

package.json에 스크립트 추가

{
  "scripts": {
    "convert-schema": "prisma-camel prisma/schema.prisma"
  }
}

실행:

npm run convert-schema

프로그래밍 방식 사용

import { convertPrismaSchema } from '@tomochandv/prisma-camel'

const schema = `
model user_profile {
  id         Int    @id @default(autoincrement())
  user_name  String
  created_at DateTime @default(now())
}
`

const converted = convertPrismaSchema(schema)
console.log(converted)

📖 변환 예시

변환 예시는 위 영어 섹션을 참고하세요.

🎯 주요 특징

1. 데이터베이스 호환성

자동으로 @map() 속성을 추가하여 데이터베이스 컬럼명을 유지합니다:

// 데이터베이스는 여전히 snake_case 사용
userName String @map("user_name")

2. 안전한 변환

  • 유효한 snake_case 패턴만 변환
  • 기존 @map() 속성 보존
  • 주석 및 포맷팅 유지
  • generator/datasource 블록은 변경하지 않음

3. 타입 참조 자동 업데이트

relation의 모델 참조를 자동으로 업데이트:

author user_profile @relation(...)  // 변환 전
author userProfile @relation(...)   // 변환 후

📚 API

convertPrismaSchema(schema: string): string

Prisma 스키마 문자열을 snake_case에서 camelCase로 변환합니다.

toCamelCase(str: string): string

snake_case 문자열을 camelCase로 변환합니다.

isSnakeCase(str: string): boolean

문자열이 snake_case 형식인지 확인합니다.

🛠 개발

# 의존성 설치
npm install

# 테스트 실행
npm test

# 커버리지 포함 테스트
npm run test:coverage

# 린트
npm run lint

# 코드 포맷팅
npm run format

# 빌드
npm run build

📄 라이선스

MIT © tomochandv

🤝 기여

이슈 및 풀 리퀘스트는 언제나 환영합니다!

🔗 링크