Zero Signup ToolsFree browser tools

Developer Tools

JSON to Prisma Schema Converter

Generate a Prisma schema from any JSON object or array in your browser. Infers scalar types, ISO dates, relations, and ids for a ready-to-use schema.prisma.

JSON to Prisma schema converter

Paste JSON, get a Prisma schema

A single object, or an array of objects to merge.

3 models · 37 lines

Root model

Name for the top-level model.

If this key is an Int or String it becomes the @id. Otherwise a cuid() id is added.

Datasource

Connector for the header block.

Supports scalar lists (String[], Int[]).

Nested objects

How nested objects and arrays of objects are modeled.

Output options

Extra controls applied during generation.

Schema notes

Things to review before migrating

  • Relation field User.profile links to Profile via the userId foreign key. Adjust the foreign-key type if the parent id is an Int.
  • Relation field User.posts links to Post via the userId foreign key. Adjust the foreign-key type if the parent id is an Int.

How types are mapped

  • JSON string becomes String, or DateTime when the value parses as an ISO-8601 date.
  • Whole numbers become Int, or BigInt past the 32-bit range. Numbers with a decimal point become Float.
  • true and false become Boolean.
  • A value that is only ever null, or an array mixing types, becomes Json.
  • A nested object becomes its own model; an array of objects becomes a one-to-many relation.

Prisma rules applied

  • Every model gets an @id. An existing Int or String id field is used; otherwise a String @id @default(cuid()) is added.
  • Fields that are missing in some samples or seen as null are marked optional with ?.
  • A key that is not a valid Prisma identifier keeps its column name through @map("...").
  • Relations add a foreign-key scalar with a default String type. Change it to Int if the parent id is an Int.
  • Run npx prisma format after pasting to validate and re-indent the schema.

How to use

  1. Paste a JSON object into the input, or click Load sample for a worked example. An array of similar objects also works and is merged into one model.
  2. Set the root model name and which key is the id. An Int or String id becomes the @id; otherwise a cuid id is added automatically.
  3. Choose the datasource provider for the header, and decide whether nested objects become Relations or stay as Json columns.
  4. Toggle ISO date detection, the generator and datasource header, and whether missing or null fields are marked optional.
  5. Read the schema notes for anything to review, then click Copy schema, paste it into schema.prisma, and run npx prisma format to validate.

About this tool

JSON to Prisma Schema Converter takes a sample JSON document, or an array of documents, and emits a Prisma Schema Language file (schema.prisma) that matches its shape, including the generator and datasource header so the result is ready to paste into a new project. The inferrer parses the value with the browser's native JSON parser, walks the tree, and maps each value to its Prisma scalar: strings become String, or DateTime when the value parses as an ISO 8601 date and date detection is on; whole numbers become Int, promoted to BigInt past the 32-bit range; numbers with a decimal point become Float; booleans become Boolean; and a value that is only ever null, or an array that mixes types, falls back to Json so you can refine it. When the root is an array, every element is merged into one model so a key that appears in some samples but not others is marked optional with a question mark, and a value whose type varies across samples is widened, which is how you should hand the converter a set of records when you want a model that accepts every row you have. Nested objects become their own models. In Relations mode an array of objects is turned into a one-to-many relation: the child model gets a back-reference field and a foreign-key scalar, and the parent holds the list side, while a single nested object becomes a one-to-one relation; in Json columns mode the nested data is kept as a Json field instead. Prisma's hard rules are handled for you so the output validates: every model gets an id, using an existing Int or String id field (Int ids get autoincrement, String ids get cuid) or a synthetic String id with a cuid default when none is usable, and a key that is not a valid Prisma identifier keeps its real column name through an @map attribute. You can rename the root model, choose which key is treated as the id, pick the datasource connector (PostgreSQL, MySQL, SQLite, SQL Server, MongoDB, or CockroachDB), and the tool flags when a scalar list is used on a connector that does not support it. A notes panel calls out the spots to review, such as a foreign-key type that may need to be Int or a field that was only ever null. Useful for scaffolding a Prisma model from a third-party webhook payload, an API response, an existing database row export, a fixture file, or a rough sketch of the data you plan to store. Parsing, inference, and code generation all run locally in your browser, so the JSON payloads and field names you paste here never leave your device.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools