A Prisma schema viewer turns the declarative schema.prisma file into a readable map of your data model — every model, its fields and types, the attributes that constrain them, and how models relate to one another. It is handy for onboarding, documentation and quickly understanding an unfamiliar codebase, and it runs locally so private schemas stay private.
How it works
The tool tokenises the schema rather than using a regex on whole lines, so it handles nested attribute parentheses correctly. The steps are:
- Strip
//and///comments and locate each top-level block:model,enum,datasource,generator. - For each
model Name { … }block, split the body into field lines. - Parse each field as
name Type[modifier] @attr @attr(...)where the modifier is?(optional) or[](list). - Classify the type: a built-in scalar (
String,Int,Boolean,DateTime,Float,Decimal,BigInt,Json,Bytes), an enum, or another model name (a relation).
A field is a relation when its type equals a model name. A list type (Post[]) implies a one-to-many side; a singular model reference implies one-to-one or many-to-one. The @relation(fields: […], references: […]) attribute pinpoints the foreign-key column.
Tips and notes
- Optional fields (
Type?) are marked nullable; list fields (Type[]) are arrays. @id,@unique,@default(...),@updatedAtand@map(...)are surfaced per field.- Enum blocks are listed separately so you can see allowed values.
- The structured JSON output is convenient for feeding into diagram or documentation generators.