Schema Generator Knowledge Base

JSON to Prisma Schema: Auto-Generate Prisma Model Definitions

Generate Prisma schema model blocks from any JSON. Infers field types, @id, @default, and nested relations. Free, browser-only JSON to Prisma generator.

Accelerate Prisma Schema Development

Writing Prisma model definitions by hand for complex data structures is repetitive and error-prone. By pasting a sample JSON object, our generator produces a complete schema.prisma model block in seconds.

Type Mapping: JSON to Prisma

  • string → String
  • integer → Int
  • float → Float
  • boolean → Boolean
  • ISO date string → DateTime
  • null → optional field (String?)
  • Nested object → separate model block with relation

Workflow: JSON API → Prisma → Database

  1. Capture a sample API response JSON
  2. Paste into the generator and set the model name
  3. Copy the output into your schema.prisma file
  4. Run prisma migrate dev to apply the schema
json
// JSON Input
{ "id": 1, "name": "Alice", "email": "a@example.com",
  "createdAt": "2024-01-01T00:00:00.000Z", "active": true }

// Generated Prisma Schema
model User {
  id          Int       @id @default(autoincrement())
  name        String
  email       String
  createdAt   DateTime
  active      Boolean
}

Try the free JSON to Prisma

Runs entirely in your browser — no upload, no signup, and your data never leaves your device.

Open JSON to Prisma

Frequently Asked Questions

Does the generator add @id automatically?

Yes. If a field named id or _id is detected, it is marked with @id. Otherwise a synthetic id Int @id @default(autoincrement()) is added.

Are relations between models generated?

Nested objects generate separate model blocks with @relation fields and foreign key columns.

Can I include the datasource block in the output?

Yes. Toggle "Include datasource" in the toolbar to prepend a full datasource db and generator client block.

Tools mentioned in this guide

Related JSON Topics & Reference Articles