100% Client-Side Engine • Zero Server Transfer • Spec: Prisma Schema Language (PSL) v5.x / DDL Abstract Syntax Tree

JSON to Prisma Schema Model Generator

Convert JSON to Prisma schema models online. Infers Int, String, Boolean and DateTime columns, marks @id primary keys and optional fields. Free, no upload.

Direct Answer & Summary

To turn JSON into a Prisma model, paste a representative record on the left. Each property is mapped to a Prisma scalar type such as Int, String, Boolean or DateTime, an id field becomes @id @default, and the right pane returns a block you can paste into schema.prisma.

Workflow Mode:
JSON Input
Prisma Schema
Prisma schema will appear here…

📊 Real-Time Structural Payload Evaluation

Spec: Prisma Schema Language (PSL) v5.x / DDL Abstract Syntax Tree100% Client-Side Engine
Total Object Keys
0
Recursive key instances
Max Nesting Tier Depth
Tier 0
AST hierarchy layers
Array Structure Instances
0
Indexed list vectors
Stream Footprint (KB)
0.00 KB
0 bytes UTF-8
Memory Allocation Topology
0 Objects0 Arrays0 PrimitivesRoot: Standby
Runtime Telemetry & Structural SynthesisUpdated Just Now
Initializing client-side V8 parser for JSON to Prisma. Awaiting input payload stream to compute live topological graphs, heap memory consumption, and key serialization density.
Topology: Standby / Awaiting InputKey Density: 0.00 keys/KBV8 Heap Footprint: ~0.00 KB

Programmatic Execution Modules

Native runtime recipes for automated pipelines • Zero external cloud dependencies

$npx prisma db pull && npx prisma format
// Dynamic PSL Generator with scalar mapping
export function inferPrismaField(key: string, val: unknown): string {
  if (val === null) return `${key} String?`;
  if (typeof val === 'number') {
    return Number.isInteger(val) ? `${key} Int` : `${key} Float`;
  }
  if (typeof val === 'boolean') return `${key} Boolean`;
  if (Array.isArray(val)) return `${key} String[]`;
  if (typeof val === 'object') return `${key} Json`;
  return `${key} String`;
}
⚙️ Engineering Edge-Case Analysis & Invariants

IEEE 754 Float Coercion vs 64-Bit Integer Precision

Numeric Coercion Heuristics

JavaScript numbers are double-precision floats (64-bit). Ingesting timestamps or database IDs exceeding 2^53 - 1 causes precision truncation. The parser maps standard integers to Int, large integers to BigInt, and fractional numbers to Float/Decimal.

Directive:Flag integers exceeding 9,007,199,254,740,991 as BigInt scalar definitions.

Composite Sub-Documents vs Relational Foreign Keys

Relational Topology Heuristics

Nested JSON objects can be mapped either as PostgreSQL Jsonb scalar columns or as distinct relational models linked via foreign keys (@relation). The parser synthesizes standalone child models when primary key patterns are detected.

Directive:Isolate nested objects with unique identifiers into standalone models referencing the parent ID.

📚 Task-Specific Reference Guides & Specifications

1 Technical Guides

Frequently Asked Questions: JSON to Prisma

How does the schema generator distinguish PostgreSQL relational models from MongoDB document models in schema.prisma?

The generator differentiates provider-specific schema requirements at the AST level. For relational targets (PostgreSQL, MySQL, SQLite), primary keys map to relational ID conventions such as `id Int @id @default(autoincrement())` or `id String @id @default(uuid())`, and nested entities trigger foreign key relations (`@relation(...)`). Conversely, for MongoDB datasource providers, primary keys require strict ObjectId mapping syntax: `id String @id @default(auto()) @map("_id") @db.ObjectId`. Additionally, nested JSON structures in MongoDB can be mapped to Prisma composite types (`type SubDocument { ... }`) rather than standalone relational models.

How are Prisma attribute directives (@id, @default, @updatedAt, @unique) inferred from JSON keys?

The engine applies heuristic attribute pattern matching: properties matching `id`, `_id`, or `uuid` are assigned the `@id` directive with an appropriate generator (`@default(autoincrement())` for integers or `@default(uuid())` for strings). Fields representing creation dates (`createdAt`) receive `@default(now())`, while modification timestamps (`updatedAt`) receive `@updatedAt`. Distinct identifier fields (such as `email`, `slug`, or `username`) receive the `@unique` constraint to enforce schema-level uniqueness.

How does scalar type inference classify numbers into Prisma Int, BigInt, Float, and Decimal types?

JSON specifies a single numeric representation (IEEE 754 float). The generator inspects values across all sample rows: integers within the signed 32-bit range (`-2,147,483,648` to `2,147,483,647`) map to Prisma `Int`. Numbers exceeding 32-bit thresholds map to `BigInt`. Non-integer fractional values map to `Float` by default, or to `Decimal` (with `@db.Decimal(10, 2)`) when property names denote currency or financial transactions (`price`, `amount`, `balance`, `subtotal`), preventing floating-point rounding inaccuracies.

How are nested JSON objects and arrays resolved between relational models and composite embedded types?

When an input payload contains nested objects (e.g. `{ user: { address: { street: "..." } } }`), the generator can resolve the relationship in two ways. In relational mode (PostgreSQL), it synthesizes a secondary `Address` model and establishes a 1-to-1 or 1-to-many `@relation(fields: [addressId], references: [id])` foreign key binding. In denormalized or document mode (MongoDB/PostgreSQL JSON columns), it emits the field as a native `Json` scalar type or a composite type (`type Address`), avoiding unnecessary table joins.

How are null values and absent properties translated into Prisma optional modifiers (?) and default fallbacks?

In Prisma schema syntax, fields marked with `?` denote database nullable columns (`NULL`), whereas unmarked fields are strictly `NOT NULL`. If an input payload contains explicit `null` values or if a key is absent in some records across a multi-object JSON array, the generator marks the field as optional (e.g. `bio String?`, `deletedAt DateTime?`). For boolean flags and counters with absent values, it can infer default fallbacks (e.g. `Boolean @default(false)` or `Int @default(0)`), ensuring valid migrations without schema validation rejections.

🔍 Developer Query Intent Index

json to prisma schema onlinefree json to prisma converterprisma schema generator onlineprisma model generator from jsongenerate schema.prisma from jsonjson to prisma ormprisma schema from api responsejson to prisma postgresql modeljson to prisma mongodb objectidinfer optional fields schema.prisma
How to use the

How to use the JSON to Prisma

Step-by-step workflow — executed 100% locally in your browser memory.

  1. 1

    Paste a representative record

    Put one object — or an array of them — into the left-hand input pane. An array lets the generator work out which fields are optional.

  2. 2

    Name the model

    Set the model name in PascalCase singular, which is the Prisma convention: `User`, not `users`.

  3. 3

    Read the generated model

    The right-hand pane shows a model block with typed fields, an @id on the primary key, and @default(now()) on timestamp-looking fields.

  4. 4

    Add relations, then migrate

    Wire up relation fields by hand, then run `prisma migrate dev` against a development database.

⚡ Technical Specifications & Engineering Compliance Matrix

Specification StandardPrisma Schema Language (PSL) v5.x / DDL Abstract Syntax Tree
Architecture:ast-compiler
Time ComplexityO(N) single-pass type inference with relationship synthesis
Memory FootprintO(M + F) where M = models, F = total AST fields
Data Privacy & EgressZero remote transmission (100% in-browser memory)
Last reviewed by the JSON2X Core Team.
Authoritative Standards & Reference Specifications:Prisma ORMJSON

Architecture: ast-compiler •Spec: Prisma Schema Language (PSL) v5.x / DDL Abstract Syntax Tree •Last reviewed by the JSON2X Core Team.