JSON to Prisma
Paste or drop your data here, or open a file.
New to Bracely?
Everything stays in your browser.
Output appears here
Paste or open your data in the input box. It never leaves your browser.
JSON to Prisma
Paste a JSON sample, such as an API response, and Bracely writes a Prisma schema for it. Each object becomes a Prisma model with @id on id fields, snake_case keys mapped with @map, and nested objects as relations with a foreign key, ready for prisma migrate dev.
Example: blog posts with their authors
Each post has a nested author. The author becomes its own model, linked by authorId, and createdAt stays String because JSON has no date type; change it to DateTime before migrating:
Input
[
{
"id": 1,
"title": "Hello JSON",
"slug": "hello-json",
"published": true,
"views": 120,
"author": {
"id": 7,
"name": "Ananya",
"email": "ananya@example.com"
},
"tags": [
"json",
"api"
],
"createdAt": "2026-10-01T09:30:00Z"
},
{
"id": 2,
"title": "Draft",
"slug": "draft",
"published": false,
"views": 0,
"author": {
"id": 8,
"name": "Kabir",
"email": "kabir@example.com"
},
"tags": [],
"createdAt": "2026-10-12T14:05:00Z"
}
]Output
// Prisma schema from sample JSON: check the types and links, then run npx prisma migrate dev
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Post {
id Int @id
title String
slug String
published Boolean
views Int
tags String[]
createdAt String
author Author? @relation("Post_author", fields: [authorId], references: [id])
authorId Int? @unique
}
model Author {
id Int @id
name String
email String
postAuthor Post? @relation("Post_author")
}
How do I use the JSON to Prisma?
- Paste a JSON sample.
- Set the root type name, for example Order.
- Copy the Prisma code into your project.
What does the JSON to Prisma do?
- model blocks with Int, Float, String, Boolean and String[]
- @map for JSON names that aren't camelCase
- Nested objects as related models
- Nested objects become their own named types
- 20 other languages from the same sample, including TypeScript
When to use the JSON to Prisma
Starting a database from data you already have, such as an API response, a fixture or an export, is faster when the schema comes from it. Paste the records and copy a Prisma schema with a model for each kind of object, then run npx prisma migrate dev to create the tables.
Each object becomes a model with @id on its id field. JSON names that aren't camelCase get a camelCase field and @map, so the column keeps the original name. A nested object becomes its own model, linked with a foreign key and @relation; a field missing from some items becomes optional (?). The datasource is PostgreSQL; change the provider for MySQL or SQLite.
Frequently asked questions
- An author can have many posts. How do I change the relation?
- When the sample has two posts by the same author (the same id), Bracely makes it many-to-one by itself: no @unique, and Author gets posts as a list. With every author different, as here, it can only see one-to-one; remove @unique from authorId and make the back-relation Post[] if authors write many posts.
- Why does tags String[] fail on MySQL?
- Lists of values are a PostgreSQL feature in Prisma (also CockroachDB and MongoDB). On MySQL or SQLite use Json for the field, or a separate Tag model with a relation.
- How does it pick Prisma types?
- From the values in your sample: whole numbers, decimals, text, true/false, arrays and nested objects. When array items disagree, the field is made optional or widened.
- Can I generate other languages?
- Yes. Change Language to any of the others: TypeScript, Go, Python, Pydantic, Java, C#, Kotlin, Swift, Rust, Scala, Ruby, Dart, PHP, Zod, TypeBox, Valibot, Yup, GraphQL, Protobuf and Drizzle.
- Is my data uploaded?
- No. Bracely runs entirely in your browser, so nothing you paste or open leaves your device.
More JSON tools
Bracely has 104 JSON tools in one page. Related ones:
- JSON to Drizzle
- JSON to Scala
- JSON to Ruby
- JSON Schema builder
- JSON Schema validator
- JSON data dictionary
- OpenAPI from JSON
- JSON to ER diagram
- JSON Schema to TypeScript
- OpenAPI to TypeScript
- GraphQL to TypeScript
- Avro to code
- API test generator
- cURL to k6
- TOML to JSON
- JSON Lines / NDJSON
- UUID generator
- JSON hash
- Code screenshot
- HTML to JSX
- JSON Formatter
- JSON Validator
- JSON Viewer
- JSON Repair
- JSON Diff
- JSON to YAML
- JSON to CSV
- jq Playground
Runs entirely in your browser. Nothing you paste is uploaded. Made by Saurabh Pagrut · About · Privacy policy
Last updated · Version 6.1 · Changelog
Saurabh Pagrut on GitHub · LinkedIn · X · YouTube · Instagram