curly{bits}

curlybits / JSON to Prisma

JSON to Prisma Schema Generator

Paste a JSON object (or an array of them) and get Prisma models for schema.prisma. Nested objects become related models with the foreign keys and @relation attributes filled in, arrays of objects become one-to-many relations, and every field gets a sensible Prisma type.

Input JSON
schema.prisma

      

How to use the JSON to Prisma Schema Generator

  1. Paste JSON into the left box, or click Load sample.
  2. Set the Root model name and pick your Database.
  3. Check the generated models: rename fields, add @unique or @default where you need them.
  4. Click Copy, paste into prisma/schema.prisma, and run npx prisma migrate dev. On Prisma 7, set the database URL in prisma.config.ts first.

How JSON maps to Prisma

JSONPrisma
Whole numberInt (or BigInt beyond 2,147,483,647)
Decimal numberFloat (switch to Decimal for money)
true / falseBoolean
ISO date string, e.g. "2026-10-24T09:30:00Z"DateTime
Other stringsString
Nested objectA related model, one-to-one, with a @unique foreign key
Array of objectsA related model, one-to-many, with the foreign key on the child
Array of strings or numbersString[] / Int[] on PostgreSQL, Json on MySQL and SQLite
null, or missing in some itemsAn optional field (?)

IDs

A key called id becomes the primary key: Int @id @default(autoincrement()) for numbers, String @id @default(uuid()) for UUIDs. Models without an id get one added, because every Prisma model needs a unique identifier. Keys that aren't valid Prisma field names (like first-name) are renamed to camelCase and keep the original column name with @map.

Prisma 7 or Prisma 6?

Prisma 7 moved the database connection URL out of schema.prisma into a prisma.config.ts file, and uses the new prisma-client generator, which writes the client into your source folder. Pick 7 for new projects. Pick 6 if your project still has url = env("DATABASE_URL") in its schema and imports from @prisma/client. The models themselves are the same in both.

Review before you migrate

JSON doesn't say which fields should be unique, indexed or required, or whether a nested object is really shared between records. Treat the output as a solid first draft: check relations, add @unique to things like emails, and use Decimal for prices. On MySQL with relationMode = "prisma", an @@index on each foreign key is added for you.

Frequently asked questions

Does it support MongoDB?

Not yet. MongoDB models use @db.ObjectId ids and embedded types, which work differently. Choose PostgreSQL, MySQL or SQLite.

Why did a list become Json?

Scalar lists like String[] are only supported on PostgreSQL (and CockroachDB). On MySQL and SQLite they're stored as Json.

Can I get TypeScript types instead?

Yes, use JSON to TypeScript, or JSON to Zod for runtime validation. Prisma also generates types from your schema when you run prisma generate.

Is my data uploaded?

No. The models are generated in your browser.

Updated

Add this JSON to Prisma schema converter to your website

Free for blogs, schools and businesses. Copy the code below and paste it into your page's HTML. The tool works exactly like this one and runs in your visitors' browsers, so nothing is uploaded. Please keep the credit line so others can find it too.

Preview embed ↗