The `prisma-json-types-generator` is a development-time tool that enhances the Prisma client by providing strict TypeScript typings for `Json` and `String` fields, replacing Prisma's default `JsonValue` with custom, user-defined interfaces. The current stable version is `4.1.1`, which primarily supports Prisma 7 and above, with earlier `v3.x` releases supporting Prisma 6. This package operates during the `prisma generate` step, ensuring all type transformations occur at compile-time without introducing any runtime overhead. Its release cadence generally follows major Prisma version updates, with patch releases for bug fixes and minor improvements. Key differentiators include robust type-safety for complex JSON structures, the ability to define string literal enums without relying on native database enums, flexible type configuration through global namespaces or inline annotations, and compatibility with multiple Prisma clients in a single project. It works seamlessly across all database drivers supported by Prisma.
npm install prisma-json-types-generatorNo compatibility data collected yet for this library.
This quickstart demonstrates how to configure the `prisma-json-types-generator` in `schema.prisma` to apply custom TypeScript types to a `Json` field. It then shows how to interact with the Prisma client, benefiting from compile-time type-safety and autocompletion for the `settings` field.
For Prisma 7+, use `prisma-json-types-generator@^4`. For Prisma 6 and below, use `prisma-json-types-generator@^3`.
Review GitHub issue #542 for details on the v3.x maintenance status. Consider upgrading to v4.x and Prisma 7 for active development and support.
Upgrade to `prisma-json-types-generator@4.0.1` or later to ensure correct type generation for update inputs with Prisma 7.
Ensure you are on `prisma-json-types-generator@4.0.0` or higher for correct typing in `groupBy` scenarios involving JSON fields and lowercase model names.
Upgrade to `prisma-json-types-generator@4.1.1` or later to fix type generation for nullable `Int` or `Float` fields in `where` clauses without explicit annotations.
Ensure `prisma generate` has been run after configuring the generator in `schema.prisma`. Verify `prisma-json-types-generator` is correctly listed as a generator provider and that its version is compatible with your installed `prisma` and `@prisma/client` versions (v4+ for Prisma 7+, v3 for Prisma 6).
Update `prisma-json-types-generator` to version `4.0.1` or later, which contains fixes for correctly applying the `Prisma.` namespace prefix in generated types.