ormbridge
v0.15.0
Published
Convert ORM models between frameworks and languages (Django, Prisma, TypeORM, Doctrine, Laravel). Define your data model once and share typed schemas across your stack.
Maintainers
Readme
ormbridge
- Author: Richard McQuiston
- Website: https://richardmcquiston.com/
Table of Contents
| Overview | Getting Started | More Information | Buy Me a Coffee | License | Copyright |
Overview
ormbridge converts data models from one Object-Relational Mapper (ORM) to another. You define a model once and share it across your whole stack. Use it from the command line or from code.
It reads source files with tree-sitter, so you do not need Python, PHP, Go, or a database. The default preserve mode keeps your table and column names, so a new tool can sit on top of the database you already have. When something cannot be converted, ormbridge prints a warning that names the model and field.
| Format | Read | Write | Notes |
| --------------------------- | :--: | :---: | ------------------------------------------------------------------------------------------------------------------------------------ |
| Django models | ✔ | ✔ | models.py files or models/ packages |
| Prisma schema | ✔ | ✔ | All six providers; Prisma 7 header with --prisma-version 7 |
| TypeORM entities | ✔ | ✔ | Decorator-based entity classes |
| Doctrine ORM entities (PHP) | ✔ | ✔ | PHP 8 attributes; one file per entity |
| Laravel (PHP) | ✔ | ✔ | Reads migrations plus Eloquent models; writes both |
| GORM (Go) | ✔ | ✔ | Structs with gorm tags; one file per model |
| Drizzle ORM (TypeScript) | ✔ | ✔ | pgTable, mysqlTable, sqliteTable plus relations() |
| Zod schemas (TypeScript) | ✔ | ✔ | Reads Zod 3 and Zod 4 z.object schemas; writes Zod 4 schemas and inferred types |
| JSON Schema / OpenAPI | ✔ | ✔ | Draft 2020-12, 2019-09 and 7, and OpenAPI components.schemas (JSON) |
| SQL DDL | ✔ | ✔ | Tables and migrations: PostgreSQL, CockroachDB, MySQL, SQLite, SQL Server, ClickHouse (write only) |
| SQLAlchemy / SQLModel | ✔ | ✔ | SQLAlchemy 2.0 (declarative, Column(), Table()) and SQLModel |
| Sequelize (JavaScript/TS) | ✔ | ✔ | Sequelize 6 and 7, sequelize-cli migrations; writes TypeScript, sequelize-cli (--style define) or v7 decorators (--style v7) |
| Entity Framework Core (C#) | ✔ | ✔ | EF Core 8: annotations or --style fluent, a DbContext; replays migrations; OwnsMany |
| Hibernate / JPA (Java) | ✔ | ✔ | Hibernate 6 jakarta or 5 --style javax; @EmbeddedId keys; Lombok option |
| TypeScript interfaces | | ✔ | Plain interfaces and enums for front ends |
| Graphene (graphene-django) | | ✔ | GraphQL types, queries and mutations that pair with Django |
| Neo4j (Cypher) | | ✔ | Node constraints and indexes; relationships as comments; --style enterprise for Enterprise |
| Spring Data Neo4j (Java) | | ✔ | SDN 7 for Spring Boot 3: @Node, @Relationship, @RelationshipProperties classes |
| neomodel (Python, Neo4j) | | ✔ | StructuredNode classes, relationships with cardinality, StructuredRel for join tables |
Each format has a guide and a runnable example project.
Getting Started
Prerequisites
- Node.js 20 or newer.
Installation
npm install --global ormbridgeYou can also run it without installing: npx ormbridge convert ....
Usage
Run ormbridge convert with an input, an output, and optionally the formats:
ormbridge convert -i ./shop/models.py -o ./prisma/schema.prismaDjango (.py), Prisma (.prisma), and SQL (.sql) files are detected from the file extension. For every other format, add --from or --to. List all formats with ormbridge formats.
Useful options:
--naming preserve|normalize: keep existing names (default), or write singular snake_case names with UUID keys.--provider <name>: the database to target:postgresql,mysql,sqlite,sqlserver,mongodb,cockroachdborclickhouse.cockroachdbkeeps the PostgreSQL types and warns about every difference (64-bit integers,unique_rowid()keys, no hstore or range types). MariaDB and Percona Server are MySQL-compatible, so usemysqlfor them.clickhouseis written by--to sqlonly.--dry-run: show what would be written, and write nothing.--check: exit with code 3 if an output file is out of date. Use it in Continuous Integration (CI).
You can keep your settings in an ormbridge.config.json file. See the command line reference for every option, the config file, and exit codes.
Examples
Prisma to Django:
ormbridge convert -i ./prisma/schema.prisma -o ./shop/models.pyA TypeORM project to Prisma (a folder needs --from):
ormbridge convert --from typeorm -i ./src/entities -o ./prisma/schema.prismaPrisma to Zod schemas, and Zod schemas to Prisma (a folder needs --from zod):
ormbridge convert -i ./prisma/schema.prisma --to zod -o ./src/schemas.ts
ormbridge convert --from zod -i ./src/schemas -o ./prisma/schema.prismaPrisma to a Neo4j Cypher schema (constraints and indexes; --style enterprise adds Enterprise Edition statements):
ormbridge convert -i ./prisma/schema.prisma --to neo4j -o ./neo4j/schema.cypherPrisma to Spring Data Neo4j entities (Java, for Neo4j):
ormbridge convert -i ./prisma/schema.prisma --to sdn -o ./src/main/javaPrisma to neomodel classes (Python, for Neo4j):
ormbridge convert -i ./prisma/schema.prisma --to neomodel -o ./app/models.pyFail a build when generated files are out of date:
npx ormbridge convert --checkUse it from code:
import { convertText } from 'ormbridge';
const result = await convertText(
[{ path: 'schema.prisma', text: prismaSource }],
{
from: 'prisma',
to: 'django',
naming: 'preserve',
provider: 'postgresql',
header: true,
autoField: 'int',
}
);
if (result.ok) {
console.log(result.value.output);
}The API reference lists every function. Each folder in examples/ is a project you can run.
More Information
- Command line reference: options, config file, exit codes, multi-file output, and naming modes.
- Format guides: what each format reads and writes, and what it loses.
- Examples: one runnable project per format.
- Field mapping: how each field type converts.
- Limitations and warnings: what cannot be converted, and how it was tested.
- Conversion matrix: what survives a round trip between every pair of formats.
- API reference:
convertText, the format registry, and more. - Changelog and roadmap.
- Test guide: how the tests and the optional real-tool checks work.
Buy Me a Coffee
If this app, code, or repository has helped you or someone you know, please consider donating. I appreciate any help to offset the costs of development and/or AI Credits.
Donate via Stripe, or scan:
License
MIT
Copyright
(c)2026 Richard McQuiston. All rights reserved.
