A command-line tool to convert SQL scripts into Entity-Relationship (ER) diagrams.
Designed to work with PostgreSQL syntax.
Report a Bug
·
Request a Feature
Checkout web version powered by WebAssembly
Input: test.sql
begin;
create table users (
user_id serial primary key
, user_name varchar(255) not null unique
, email varchar(255) not null unique
, password text not null
, created_at timestamptz default now()
, updated_at timestamptz default now()
);
create table user_profile_image (
user_id int references users on delete cascade primary key
, user_profile_image text not null
, created_at timestamptz default now()
, updated_at timestamptz default now()
);
...Command:
./sql2er-exe test.sql -o erd.jpegOutput:
-
Download the binary from the Releases page.
-
Run the tool:
./sql2er-exe test.sql -o erd.jpeg
-
Clone the repository and navigate to the project root.
-
Build the binary for linux:
stack build cp $(stack path --local-install-root)/bin/sql2er-exe . ./sql2er-exe test.sql -o erd.jpeg
- Install
wasm32-wasi-cabalfrom here - Make sure to download the
9.8FLAVOUR.
wasm32-wasi-cabal build sql2er-wasm -f build-sql2er-wasm
cp path/to/sql2er-wasm.wasm .
python3 -m http.server- Add Changelog
- Add Test Cases
- Support
GENERATEDConstraint - Gracefully Ignore Partitions
- Support
bigserial - Add Additional Examples
- Enhance Documentation
- Add More Parsing Functions
- Support Interval Data Type
- Support 2D Arrays
For the full list of proposed features and known issues, check out the open issues.
- Needs internet connection since, We are sending request to mermaid API.
- Syntax Validation:
The parser doesn't validate SQL syntax; it extracts only the necessary information for generating ER diagrams. - PostgreSQL Specific:
Designed and tested using PostgreSQL 17.
DETACHUSING ...TABLESPACENOT VALIDVALIDATEINTERVALData Type
This project was inspired by sqldiagram, which focuses on MySQL but lacked robust parsing capabilities.
