JSON to Prisma Schema

Prisma ORM

Generate schema.prisma models from JSON documents with automatic primary keys, timestamps, @map attributes, and foreign-key relations.

Sample JSON
Valid JSON JSON
schema.prisma
0 models Prisma Schema

About This Tool

Bootstrapping a Prisma schema from existing API responses or NoSQL documents normally requires manually typing out every field, scalar type, and @map annotation. This converter inspects your JSON structure and builds a complete schema.prisma file in real time.

It recognizes UUIDs, ISO 8601 dates, email/slug uniqueness candidates, and created_at/updated_at audit columns, adapting scalar list types automatically for PostgreSQL, MySQL, or SQLite.

Key Features

  • Relational Decomposition: Splits nested JSON objects and object arrays into linked Prisma models with foreign-key fields and onDelete: Cascade.
  • Provider-Aware Types: Uses native String[] and @db.Uuid on PostgreSQL while falling back safely to Json columns on MySQL and SQLite.
  • CamelCase Normalization: Converts snake_case database keys into camelCase Prisma Client properties while preserving physical column names via @map.

Frequently Asked Questions

How does the generator decide between @default(uuid()), @default(cuid()), and @default(autoincrement())?
When an id or _id field is an integer, it emits Int @id @default(autoincrement()). When the value matches a canonical UUID string, it emits String @id @default(uuid()) (plus @db.Uuid on PostgreSQL). Otherwise it emits String @id @default(cuid()).
How are nested JSON objects and arrays mapped across database providers?
In Relation Models mode, nested objects and object arrays generate separate Prisma models linked with @relation(fields: [...], references: [id]). In Scalar Json mode, nested structures map to the Prisma Json scalar type.
Why are primitive arrays mapped to Json when MySQL or SQLite is selected?
PostgreSQL supports native scalar arrays (String[], Int[]), whereas MySQL and SQLite do not support native scalar lists in Prisma and require storing primitive arrays as Json.
What does snake_case @map do?
When enabled, snake_case JSON keys like "created_at" become idiomatic camelCase Prisma fields (createdAt) annotated with @map("created_at"), and the model receives a table-level @@map("plural_table_name") attribute.