jsondecode.com logo

JSON to Prisma Schema Model Generator — Free Online

Convert JSON to a Prisma schema model with correct field types, @id, @default, and @map directives using AI. For PostgreSQL, MySQL, and SQLite. Free, no sign-up.

JSON to BigQuery Schema Converter — Free Online ToolJSON to React Flow Diagram — Convert JSON Online FreeJSON to Go Struct with BSON Tags — Free Online ToolJSON to TypeScript Interface Generator — Free OnlineJSON to YAML Converter — Convert JSON to YAML OnlineJSON to CSV Converter — Export JSON Array to CSV FreeJSON to Python Dataclass Generator — Free Online ToolJSON to SQL INSERT Statement Generator — Free OnlineJSON to Markdown Table Converter — Free Online ToolJSON to XML Converter — Convert JSON to XML Online FreeJSON to HTML Table Converter — Free Online ToolYAML to JSON Converter — Convert YAML to JSON Online FreeXML to JSON Converter — Convert XML to JSON Online FreeJSON to JSON Schema Generator — Free Online ToolJSON to GraphQL Schema Generator — Free Online ToolRuby to JSON Converter — Convert Ruby Hashes to JSON OnlineJSON to C# Class Generator — Free Online ToolJSON to Java Class (POJO) Generator — Free Online ToolJSON to Kotlin Data Class Generator — Free Online ToolJSON to Rust Struct Generator — Free Online ToolJSON to PHP Array Converter — Free Online ToolCSV to JSON Converter — Free Online ToolJSON to Dart Class Generator — Free Online ToolJSON to Swift Struct (Codable) Generator — Free OnlineJSON to Terraform HCL Variables Converter — Free OnlineJSON to Mongoose Schema Generator — Free Online ToolJSON to Protocol Buffer (proto3) Generator — Free OnlineJSON to TOML Config Format Converter — Free Online ToolTOML to JSON Converter — Convert TOML to JSON Online FreeJSON to Apache Avro Schema Generator — Free Online ToolJSON to OpenAPI 3.0 Schema Component — Free Online ToolJSON to R Data Frame Code Generator — Free Online ToolJSON to Lua Table Syntax Converter — Free Online ToolJSON to Zod Schema (TypeScript) Generator — Free OnlineJSON to Scala Case Class with Circe Codec — Free OnlineJSON to PowerShell Hashtable Converter — Free Online Tool

JSON to Prisma Schema Model Generator — Free Online

About JSON to Prisma Schema Model Generator — Free Online

JSON to Prisma Schema converts a JSON object or sample data payload into a Prisma schema model, inferring field types and adding appropriate decorators like @id, @default, and @updatedAt. Developers use it to scaffold database models quickly from existing API responses or data fixtures, eliminating manual type mapping when adopting Prisma in a new or existing project.

JSON to Prisma Type Mapping

JSON TypeExample ValuePrisma Field TypeNotes
string"hello"StringDefault mapping for all string values
string (ISO date)"2024-01-15T10:00:00Z"DateTimeDetected by ISO 8601 format heuristic
number (integer)42IntWhole numbers map to Int
number (float)3.14FloatNumbers with decimals map to Float
booleantrue / falseBooleanDirect 1-to-1 mapping
nullnullString?Null values produce optional (?) fields
object{...}JsonNested objects default to Json type
array of objects[{...}]JsonHeterogeneous arrays use Json
array of strings["a","b"]String[]Homogeneous primitive arrays use array type
id / _id field"abc123" or 1String @id or Int @id@id decorator added automatically

Prisma Schema vs Alternatives

FeaturePrisma SchemaTypeORM EntityMongoose SchemaSequelize Model
LanguagePrisma SDL (.prisma)TypeScript decoratorsJavaScript/TypeScriptJavaScript/TypeScript
Type safetyFull (generated client)Full (via decorators)Partial (via TS plugin)Partial
Auto-migrationprisma migrate devManual or synchronize:trueNo built-in migrationssequelize-cli migrate
Relations syntax@relation directive@ManyToOne etc.ref: 'Model'belongsTo / hasMany
JSON field supportJson native type@Column({type:'jsonb'})Mixed / Schema.Types.MixedDataTypes.JSON
Enum supportenum keyword@Column enum optionString with validateDataTypes.ENUM
Generated typesPrismaClient typesEntity classDocument interfaceModel class
DB supportPostgreSQL, MySQL, SQLite, MongoDB, CockroachDBMany relational DBsMongoDB onlyMany relational DBs

Frequently Asked Questions

How does JSON to Prisma schema handle nested objects?

Nested JSON objects are mapped to the Json Prisma field type by default, since Prisma does not inline nested models automatically. If you want a proper relational model, you should manually split the nested object into a separate model and add a @relation field. Prisma supports Json natively on PostgreSQL, MySQL, and MongoDB.

What Prisma field type should I use for a UUID primary key from JSON?

If your JSON id field contains a UUID string, the correct Prisma type is String with @id and @default(uuid()) decorators: id String @id @default(uuid()). The tool detects fields named id or _id and adds @id automatically. You can manually add @default(uuid()) or @default(cuid()) depending on your ID generation strategy.

Can I convert a JSON array to a Prisma schema?

Yes — the tool accepts a JSON array and uses the first object (or merges all objects) to infer the full field set, so optional fields present in only some records are detected. The resulting model represents the shape of one array element. Arrays of primitive values within a record (e.g., String[]) are rendered as Prisma list types where the database supports them.

How do I add @updatedAt and @createdAt to a Prisma model from JSON?

Fields named updatedAt or updated_at with a DateTime type automatically receive the @updatedAt decorator in Prisma, which tells the database to update the timestamp on every write. For createdAt, use @default(now()) so Prisma sets the value on record creation. You can add these manually after generation: createdAt DateTime @default(now()) and updatedAt DateTime @updatedAt.

Does Prisma support optional fields and how are they generated from JSON?

Prisma marks a field as optional by appending ? to the type, for example String?. The JSON to Prisma converter produces optional fields when a JSON value is null or when a key is missing in some records of an array input. Required fields have no ?, and Prisma will throw a runtime error if you insert a record without providing a value for them.

If jsondecode.com saved you time, share it with your team

Free forever. No ads. No sign-up. Help other developers find it.