I built a CLI tool that generates documentation from Drizzle ORM schema definitions.
The problem: Drizzle ORM doesn't have built-in schema documentation or ER diagram generation. While drizzle-dbml-generator exists for DBML output, I needed something that could also extract JSDoc comments and generate human-readable documentation.
What it does: - Extracts JSDoc comments from your schema and includes them in the output - Generates DBML (compatible with dbdocs.io and dbdiagram.io) - Generates Markdown documentation with Mermaid ER diagrams - Supports PostgreSQL, MySQL, and SQLite - Works with both Drizzle v0 (relations()) and v1 beta (defineRelations()) APIs - Watch mode for development
Example: drizzle-docs ./src/db/schema.ts -o schema.dbml drizzle-docs ./src/db/schema.ts -f markdown -o ./docs
The key differentiator is JSDoc extraction. If you document your schema like this:
/** User account information */
export const users = pgTable("users", {
/** Unique identifier */
id: serial("id").primaryKey(),
/** User's email address */
email: varchar("email", { length: 255 }).notNull(),
});
These comments become Notes in DBML or descriptions in Markdown output.Built with TypeScript, uses the TS Compiler API for comment extraction. MIT licensed.
Would love feedback on what output formats or features would be most useful.