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
π Full documentation
npm install prisma-schema-sorteryarn add prisma-schema-sorterpnpm add prisma-schema-sorterRun 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-schemaimport { sortPrismaSchema } from 'prisma-schema-sorter';
await sortPrismaSchema('./prisma/schema.prisma');
// => Successconst { 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.