A modern tool to sort Prisma schema elements alphabetically - models, enums, generators, and datasources. Keep your schema organized and maintainable.
- 🔄 Sorts all schema elements: Models, enums, generators, and datasources
- 🛠️ CLI and programmatic usage: Use it however fits your workflow
- 📦 Zero configuration: Works out of the box
- 🚀 Fast and lightweight: Built with performance in mind
- 🔧 TypeScript support: Fully typed for better development experience
npm install prisma-schema-sorter
yarn add prisma-schema-sorter
pnpm add prisma-schema-sorter
Run as a one-time command:
npx prisma-schema-sorter sort --schema="./prisma/schema.prisma"
Add to your package.json scripts:
{
"scripts": {
"sort-schema": "prisma-schema-sorter sort --schema='./prisma/schema.prisma'"
}
}
Then run with:
npm run sort-schema
import { sortPrismaSchema } from 'prisma-schema-sorter';
await sortPrismaSchema('./prisma/schema.prisma');
// => Success
const { sortPrismaSchema } = require('prisma-schema-sorter');
sortPrismaSchema('./prisma/schema.prisma').then(() => {
console.log('Schema sorted successfully!');
});
Contributions, issues and feature requests are welcome!
This project is MIT licensed.