JSON to Drizzle
Paste or drop your data here, or open a file.
New to Bracely?
Everything stays in your browser.
Output appears here
Paste or open your data in the input box. It never leaves your browser.
JSON to Drizzle
Paste a JSON sample, such as an API response, and Bracely writes Drizzle ORM tables for PostgreSQL for it. Each object becomes a pgTable from drizzle-orm/pg-core with columns typed from your data, snake_case column names, and nested objects as their own table linked by a foreign key.
Example: products with a category
Prices are in whole paise, the rating is a decimal, and the nested category becomes its own table linked by category_id. Both products have category 3, so the link is many-to-one and category_id has no unique constraint:
Input
[
{
"id": 101,
"name": "Keyboard",
"priceInPaise": 249900,
"inStock": true,
"rating": 4.6,
"category": {
"id": 3,
"name": "Accessories"
}
},
{
"id": 102,
"name": "Mouse",
"priceInPaise": 79900,
"inStock": false,
"rating": 4.2,
"category": {
"id": 3,
"name": "Accessories"
}
}
]Output
import { boolean, doublePrecision, integer, pgTable, text } from "drizzle-orm/pg-core";
export const categories = pgTable("categories", {
id: integer("id").primaryKey(),
name: text("name").notNull(),
});
export const products = pgTable("products", {
id: integer("id").primaryKey(),
name: text("name").notNull(),
priceInPaise: integer("price_in_paise").notNull(),
inStock: boolean("in_stock").notNull(),
rating: doublePrecision("rating").notNull(),
categoryId: integer("category_id").references(() => categories.id),
});
How do I use the JSON to Drizzle?
- Paste a JSON sample.
- Set the root type name, for example Order.
- Copy the Drizzle code into your project.
What does the JSON to Drizzle do?
- pgTable definitions with integer, doublePrecision, text and boolean
- snake_case column names with camelCase properties
- Nested objects as tables linked with .references()
- Nested objects become their own named types
- 20 other languages from the same sample, including TypeScript
When to use the JSON to Drizzle
Drizzle ORM describes tables in TypeScript, so queries are typed and the schema lives next to your code. Generating the tables from real records gets every column and type right, ready for drizzle-kit to create the migration.
Each object becomes a pgTable from drizzle-orm/pg-core. Properties stay camelCase in TypeScript while the columns are snake_case, as in price_in_paise. Whole numbers become integer, decimals doublePrecision, true/false boolean and lists of strings text().array(). Fields in every record are .notNull(). A nested object becomes its own table, with a column that .references() its id.
Frequently asked questions
- Why is there no .unique() on category_id?
- Both products have category 3, so many products share one category: a many-to-one link, which needs no unique constraint. When every record has its own nested object, Bracely adds .unique() for one-to-one.
- Why store money in paise?
- Whole numbers avoid the rounding errors of decimals, which is why payment APIs send amounts in the smallest unit. Bracely types whatever the JSON holds: integer for 249900, doublePrecision for 2499.5.
- How does it pick Drizzle types?
- From the values in your sample: whole numbers, decimals, text, true/false, arrays and nested objects. When array items disagree, the field is made optional or widened.
- Can I generate other languages?
- Yes. Change Language to any of the others: TypeScript, Go, Python, Pydantic, Java, C#, Kotlin, Swift, Rust, Scala, Ruby, Dart, PHP, Zod, TypeBox, Valibot, Yup, GraphQL, Protobuf and Prisma.
- Is my data uploaded?
- No. Bracely runs entirely in your browser, so nothing you paste or open leaves your device.
More JSON tools
Bracely has 104 JSON tools in one page. Related ones:
- JSON to Scala
- JSON to Ruby
- JSON Schema builder
- JSON Schema validator
- JSON data dictionary
- OpenAPI from JSON
- JSON to ER diagram
- JSON Schema to TypeScript
- OpenAPI to TypeScript
- GraphQL to TypeScript
- Avro to code
- API test generator
- cURL to k6
- Postman test script generator
- JSON5 / JSONC to JSON
- JSON to SQL
- Edge-case test data
- Password generator
- SVG to JSX
- CSS to Tailwind
- JSON Formatter
- JSON Validator
- JSON Viewer
- JSON Repair
- JSON Diff
- JSON to YAML
- JSON to CSV
- jq Playground
Runs entirely in your browser. Nothing you paste is uploaded. Made by Saurabh Pagrut · About · Privacy policy
Last updated · Version 6.1 · Changelog
Saurabh Pagrut on GitHub · LinkedIn · X · YouTube · Instagram