For typed code generated from my SQL, the strongest matches are kyleconroy/sqlc (sqlc is a SQL compiler that generates type-safe client), sqlc-dev/sqlc (sqlc is a schema-driven code generator that produces type-safe) and prisma/prisma (Prisma is a database toolkit that generates type-safe TypeScript). prismagraphql/prisma and prisma/prisma1 round out the shortlist. Each is ranked by relevance to your query, popularity and recent activity.
Tools that automatically generate type-safe code and interfaces directly from your existing database schema definitions.
sqlc is a SQL compiler and code generator that creates type-safe database client code from raw SQL queries. It transforms SQL statements into typed definitions and functions, eliminating the need for manual row mapping between database results and application structures. The tool ensures compile-time safety by validating SQL queries against the database schema before the application is run. This workflow integrates the database schema directly into the application code, deriving types from the underlying SQL definitions to prevent runtime errors. The system utilizes AST-based query analysis
sqlc is a SQL compiler that generates type-safe client code (including TypeScript) from your SQL schema and queries, with support for multiple databases and custom type mappings, making it a strong fit for compile-time safe database interactions.
sqlc is a code generation tool that compiles raw SQL queries into type-safe application code. By analyzing SQL statements against database schema definitions during the build process, it eliminates the need for manual data mapping and prevents runtime type errors. The project functions as a schema-aware generator that translates database column types into native language primitives. It distinguishes itself through a modular, plugin-based architecture that allows for the extension of the generation pipeline to support diverse programming languages and custom frameworks beyond its default capab
sqlc is a schema-driven code generator that produces type-safe client code from SQL queries and schema definitions, which directly matches the core intent; however, its default language support does not include TypeScript (it covers Go, Python, Kotlin, etc.), so it may require additional plugin configuration to generate TypeScript types, placing it as a solid match rather than the most comprehensive answer for this specific need.
Prisma is a database toolkit that provides a unified access layer for interacting with relational and document databases. It centers on a declarative schema modeling approach, where developers define their data structures in a human-readable language. This schema serves as the single source of truth, from which the toolkit automatically generates type-safe database clients that provide compile-time validation and editor autocomplete for all data operations. The project distinguishes itself through a high-performance, Rust-based query engine that handles query planning and connection pooling o
Prisma is a database toolkit that generates type-safe TypeScript clients from a declarative schema, providing multi-database support, introspection, and custom type mapping — exactly what this search asks for.
Prisma is a type-safe database object-relational mapper that uses a declarative schema to map data models to relational and document databases. It provides a unified toolkit for data access, combining a database driver with tools for schema management and record manipulation. The project features a multi-database driver that standardizes interactions across PostgreSQL, MySQL, and MongoDB. It includes a system for tracking and applying structural schema migrations across different environments and a graphical user interface for browsing and editing database records. The system ensures data in
Prisma is a type-safe database ORM that generates TypeScript types from your database schema (supporting both introspection from an existing SQL database and explicit schema definitions), covering all the requested features like multi-database support, DB introspection, and custom type mapping.
Prisma1 is a TypeScript object-relational mapper and type-safe database client designed for interacting with relational databases. It functions as a system for declarative schema modeling, where database structures are defined in a single schema file that automatically synchronizes with the underlying database. The project provides a type-safe query builder that generates a custom client to ensure database queries match defined schema types at compile time. It also includes a database GUI administrator, providing a visual web interface for browsing, editing, and managing relational database r
Prisma1 generates a type-safe TypeScript client from a declarative schema or an existing database, with introspection, multi-database support, and custom type mapping, making it a comprehensive fit for your goal of automating type-safe database code.
jOOQ is a type-safe SQL query builder for Java that generates code from live database schemas, enabling compile-time validation of SQL syntax and data types. Its core identity is built around a fluent DSL that mirrors SQL structure, a code generator that maps tables, views, and routines to Java objects, and a multi-dialect engine that translates the same DSL into vendor-specific SQL for over 30 databases. The project also includes a SQL parser and transformer for refactoring or dialect conversion, reactive stream integration for non-blocking query execution, and a JDBC proxy diagnostics tool f
jOOQ is a type-safe SQL query builder that generates compile-time-checked Java code from live database schemas, making it the right kind of tool for safe database interactions; however it produces Java classes rather than TypeScript types, so it covers the core capability but misses your specific language target.
sqlboiler is a database-first ORM generator for Go that analyzes an existing database schema to produce strongly typed structures and query helpers. It functions as a schema-driven code generator, transforming database tables and relationships into executable Go source code. The project distinguishes itself through a type-safe query builder that uses chainable modifiers to construct SQL statements, eliminating the need for raw string concatenation. It utilizes customizable text templates to generate source code, allowing for the aliasing of schema entities and the creation of custom templates
Sqlboiler automatically generates type-safe Go code from your existing database schema through introspection—it matches the core idea of a schema-driven code generator, but you explicitly asked for TypeScript types instead of Go, so it delivers the right approach for a different target language.
PostGraphile is an automated tool that converts a PostgreSQL database schema into a fully functional GraphQL API. It serves as a GraphQL execution engine and schema orchestrator, utilizing database schema introspection to retrieve strongly typed metadata directly from PostgreSQL. The project features a modular system for composing and standardizing GraphQL schemas through plugins, which manage naming conventions and connections. It includes a PostgreSQL query builder that constructs dynamic, SQL-injection-proof queries using tagged template literals. The system employs a declarative query pl
PostGraphile generates a GraphQL API from a PostgreSQL schema rather than producing type-safe TypeScript code for direct database interactions, so it does not match the specific goal of generating type‑safe database client code.
SpacetimeDB is a stateful, real-time database platform that executes application logic directly within the database engine. By unifying data storage and business logic, it allows developers to build applications where state transitions are processed through atomic, server-side functions. The platform maintains persistent connections to stream incremental updates to clients, ensuring that local caches remain synchronized with the server state at all times. The platform distinguishes itself by generating type-safe client interfaces directly from server-side schema definitions, ensuring consiste
SpacetimeDB is a stateful real-time database platform that generates type-safe client interfaces from its own schema definitions, but this search is for a dedicated tool that takes an existing SQL database schema and automatically produces type-safe code (like TypeScript types) for compile-time safety—SpacetimeDB’s code generation is a byproduct of its platform rather than its main purpose.
🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
Graphile's Crystal monorepo (home to PostGraphile) introspects a PostgreSQL schema to generate a GraphQL API and its TypeScript types, so it touches on your goal but is primarily a GraphQL API generator rather than a standalone tool for generating type-safe database-interaction code.
Liam is a database schema visualizer and interactive entity-relationship diagram generator. It parses SQL schemas and ORM formats to create visual representations of database structures, allowing users to analyze table relationships and navigate complex layouts. The project distinguishes itself through CI/CD pipeline integration, acting as a documentation automator that synchronizes diagrams with database schema changes during deployment. It supports sharing specific perspectives of a schema via coordinate-based view links that capture precise zoom levels and filtered views. The tool provide
Liam is a database schema visualizer that parses SQL schemas to produce diagrams, not TypeScript types or client code, so it does not generate the type-safe code needed for compile-time safety in database interactions.
PostgREST is a standalone web server that automatically transforms a PostgreSQL database into a RESTful API. It serves as an API gateway that translates HTTP requests into SQL queries, mapping the database schema directly to endpoints without the need for manual route definitions. The system utilizes a JWT authentication layer to validate user identities and map incoming web requests to specific database roles. This allows the server to delegate authorization and permission enforcement to the internal PostgreSQL role system. It includes a generator for OpenAPI specifications to provide stand
PostgREST turns a PostgreSQL database into a RESTful API and generates OpenAPI specs, but it does not produce type-safe client code such as TypeScript types from the schema, so it is a related but different tool than the type-safe code generator you are looking for.
| Repository | Stars | Language | License | Last push |
|---|---|---|---|---|
| kyleconroy/sqlc | 17.9K | Go | MIT | |
| sqlc-dev/sqlc | 17.9K | Go | MIT | |
| prisma/prisma | 46.4K | TypeScript | Apache-2.0 | |
| prismagraphql/prisma | 16.4K | Scala | Apache-2.0 | |
| prisma/prisma1 | 16.4K | Scala | Apache-2.0 | |
| jooq/jooq | 6.7K | Java | other | |
| aarondl/sqlboiler | 7K | Go | NOASSERTION | |
| graphile/postgraphile | 12.9K | TypeScript | MIT | |
| clockworklabs/spacetimedb | 19.2K | Rust | other | |
| graphile/crystal | 12.9K | TypeScript | MIT |