JSON to Prisma
Quick Answer
Use the JSON Schema Generator with the Prisma tab to convert JSON into Prisma model definitions. Paste your JSON to generate a starting point for your database schema. Note: not every JSON structure maps cleanly to a relational model — always review and refine the output.
What is Prisma?
Prisma is a next-generation ORM for Node.js and TypeScript. It provides type-safe database access with auto-generated queries, migrations, and a visual data browser. Prisma models define your database tables and relationships.
When to Use This Tool
- Bootstrapping a new project with existing JSON data
- Converting NoSQL documents to relational models
- Creating initial schema drafts from API responses
- Learning Prisma syntax from familiar JSON structures
Step-by-Step Instructions
- Open the tool: Navigate to the JSON Schema Generator.
- Select Prisma tab: Click on the "Prisma" tab.
- Paste your JSON: Copy your JSON sample and paste it into the input area.
- Review the model: The tool generates a Prisma model based on your JSON structure.
- Copy and refine: Copy the generated model to your
schema.prismafile. - Adjust as needed: Add relationships, constraints, and refine field types.
Example
Input JSON:
{
"id": 1,
"title": "My Post",
"content": "Post content here...",
"published": true,
"authorId": 5,
"tags": ["tech", "tutorial"],
"createdAt": "2024-01-15T10:00:00Z"
}Generated Prisma Model:
model Post {
id Int @id @default(autoincrement())
title String
content String
published Boolean @default(false)
authorId Int
tags String[]
createdAt DateTime @default(now())
}Type Mappings
| JSON Type | Prisma Type |
|---|---|
| String | String |
| Number (integer) | Int |
| Number (float) | Float or Decimal |
| Boolean | Boolean |
| Array | Type[] (scalar list) |
| Object | Separate model + relation |
| Date string | DateTime |
Important Considerations
Relationships
The tool generates flat models. You'll need to manually add relationships:
model Post {
id Int @id @default(autoincrement())
title String
content String
published Boolean @default(false)
authorId Int
author User @relation(fields: [authorId], references: [id])
tags String[]
createdAt DateTime @default(now())
}
model User {
id Int @id @default(autoincrement())
posts Post[]
}IDs and Defaults
The tool attempts to identify ID fields. Review and adjust:
id Int @id @default(autoincrement()) // Auto-increment integer // OR id String @id @default(uuid()) // UUID // OR id String @id @default(cuid()) // CUID
Constraints
Add constraints for data integrity:
email String @unique name String @db.VarChar(255)
Best Practices
- Review generated models: The tool provides a starting point, not a final schema
- Normalize data: Break nested objects into separate models with relations
- Use appropriate IDs: Choose between auto-increment, UUID, or CUID based on your needs
- Add indexes: Add
@indexfor frequently queried fields - Run migrations: Use
npx prisma migrate devafter updating your schema
Related Tools
- JSON Schema Generator - Main conversion tool
- JSON to TypeScript - For application types
FAQ
Q: Can I generate the entire schema file?
A: The tool generates model definitions only. You'll need to add the datasource and generator blocks manually.
Q: How do I handle nested objects?
A: The tool flattens nested objects. For proper relational design, extract nested objects into separate models and create relations.
Q: Does it support MongoDB?
A: Prisma supports MongoDB with a different syntax. The generated models work with relational databases (PostgreSQL, MySQL, SQL Server, SQLite).
Related tools
Markdown → Rich Text / Excel
Convert Markdown to rich text you can paste into Word, Gmail or Google Docs, or export tables to Excel.
Follow-Back Checker
Find out who you follow on Instagram or TikTok who doesn't follow you back, using your own data export.
Bulk UTM Builder
Build UTM-tagged URLs in bulk. Import CSV, paste lists, and export to CSV or XLSX.