What is DBML and why convert it to SQL?
DBML (Database Markup Language) is a format from Holistics, used in the popular dbdiagram.io tool. It lets you describe a database schema in a clean, compact form, without the full SQL syntactic ceremony.
In DBML you write `Table users { id integer [pk] name varchar }` instead of `CREATE TABLE users (id INTEGER PRIMARY KEY, name VARCHAR(255))`. Shorter, more readable, easier to review. But eventually you need real SQL to create tables in a real database.
This tool converts DBML to SQL for PostgreSQL, MySQL, or SQLite. Supports: tables, columns with types, primary keys, auto-increment, NOT NULL, UNIQUE, defaults, indexes, foreign keys (Refs), enums. Also shows parse errors with line numbers.
How to use it
- Paste your DBML schema into the left panel. The format follows dbdiagram.io.
- Pick the target dialect: PostgreSQL, MySQL, or SQLite. Each has its own types and conventions.
- On the right you get CREATE TABLE and ALTER TABLE ready to paste into a migration or your database.
- If there are parse errors, the list appears below with line numbers. Fix the input and the output updates.
- Copy the result with the Copy button and paste into your migration tool, Prisma, Drizzle, Flyway, Liquibase, whatever you use.
- The Format result toggle runs the output through a SQL formatter for clean indentation. Disable it for raw output.
When this is useful
Common scenarios:
- Designing a new database from scratch. You start in DBML because it is faster to capture ideas than full SQL. Once the schema settles, you generate CREATE TABLE.
- Syncing a diagram with a migration. You have a diagram in dbdiagram.io (or exported from another tool) and want to create tables in a new database. The converter shortens that path.
- Technical documentation. DBML is readable for non-engineers. SQL is executable. Write once in DBML, generate SQL for developers and a diagram for the product manager.
- Schema code review before a migration. Easier to spot a mistake in DBML than in many CREATE TABLE lines.
- Learning SQL. Watch how a simple `Table users { id integer [pk] }` expands into full `CREATE TABLE "users" ("id" INTEGER PRIMARY KEY)`. A nice learning path.
After generating SQL, you may want to format it. Need an ORM schema instead? See the SQL to ORM converter.