SQL to DBML Converter
Paste SQL CREATE TABLE statements and get DBML (Database Markup Language) with relationships, indexes, and constraints. Import into dbdiagram.io and other DBML-compatible tools.
0
Tables
0
Refs
0
Columns
0
Indexes
Tip: Include
FOREIGN KEY constraints in your SQL to auto-generate Ref statements. The converter supports inline REFERENCES (PostgreSQL/MySQL) and explicit CONSTRAINT ... FOREIGN KEY syntax.
// Paste SQL CREATE TABLE statements to generate DBML
Need to compare two schemas?
SchemaLens diffs SQL schemas in your browser and generates migration scripts. Free for up to 15 tables.
Open SchemaLens Diff →How It Works
1. Paste SQL
Paste any CREATE TABLE dump. Supports PostgreSQL, MySQL, SQLite, SQL Server, and Oracle syntax.
2. Detect Relationships
Foreign keys are parsed into DBML Ref statements with cardinality notation.
3. Copy & Import
Copy the generated DBML and paste into dbdiagram.io or any DBML-compatible tool.
Supported DBML Features
- Tables & Columns: Every table becomes a DBML Table with typed columns.
- Primary Keys: Marked with
pkandincrementwhen auto-increment is detected. - Foreign Keys: Converted to
Refstatements with>or<>cardinality. - Unique Constraints: Marked with
uniqueon columns or as composite indexes. - Indexes: Composite unique constraints become
indexesblocks inside tables. - Defaults & Notes:
DEFAULTvalues and inline comments are preserved as DBML settings.