json to prisma schema model converter

typetools

instant, client-side type converter • 0ms network latency

root:
inputjson
paste or drop file
307 chars
outputprisma
*.prisma
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Metadata {
  id String @id @default(cuid())
  lastLogin DateTime
  ipAddress String
  failedAttempts Json?
}

model RootPayload {
  id String @id @default(cuid())
  userId String
  username String
  email String
  isActive Boolean
  score Float
  roles String[]
  metadata Metadata
  tags Json
}
0.15ms•in-browser
documentation, edge cases & specifications below

step-by-step integration guide

technical specification differences & end-to-end conversion workflow

Translating JSON API Payloads into Declarative Prisma Schema Models

Prisma ORM uses its own declarative modeling language (schema.prisma) as a single source of truth to generate both SQL migrations (via Prisma Migrate) and type-safe TypeScript database clients (Prisma Client). Converting a JSON object graph into Prisma models requires mapping hierarchical JSON conventions into Prisma's scalar types (String, Int, BigInt, Float, Decimal, Boolean, DateTime, Json) and block/field attributes. Furthermore, Prisma enforces strict naming conventions where models use singular PascalCase identifiers and database column names in snake_case are bound to camelCase TypeScript fields using the @map("column_name") attribute.

Model Normalization, @id Detection, and Relational vs. Json Scalar Trade-offs

When you paste a JSON document into our Prisma converter, the AST analyzer inspects the root object and all nested child structures. Fields named id or _id are annotated with @id alongside appropriate default generators—such as @default(uuid()) for UUID strings or @default(autoincrement()) for sequential integers. Whenever a JSON property uses snake_case (e.g., created_at), the generator emits a clean camelCase Prisma field (createdAt DateTime @default(now()) @map("created_at")) so your TypeScript code stays idiomatic while matching your existing database columns. Nullable properties are marked with Prisma's postfix ? modifier, and nested child objects are extracted into related Prisma model blocks with foreign-key relation scalars.

frequently asked questions

common developer questions answered

q:How does the converter map snake_case JSON keys to camelCase Prisma fields?

The generator converts snake_case keys (like user_id) into camelCase Prisma field names (userId) and appends the @map("user_id") attribute so Prisma Client uses camelCase in TypeScript while querying the exact snake_case database column.

q:When should a nested JSON object be a separate Prisma model vs. a Prisma 'Json' scalar?

If you need to filter, join, or enforce foreign-key constraints on nested properties, extracting a separate Prisma model is best. If the nested object is unstructured metadata or config, using Prisma's native 'Json' scalar type avoids unnecessary table joins.

q:Does Prisma support arrays of primitives like String[] or Int[]?

Prisma supports scalar lists (String[], Int[]) natively when using PostgreSQL, CockroachDB, or MongoDB connectors. For MySQL or SQLite, scalar lists are stored via a Json column or related table.

topic cluster

related type & ast converters

3 interconnected tools