Sql2er
Generate ER-diagram using SQL file
Install / Use
/learn @tusharad/Sql2erREADME
Table of Contents
Checkout web version powered by WebAssembly
Example
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.jpeg
Output:
<img src="example/erd.jpeg" alt="ER Diagram" width="100%" height="580">Getting Started
Option 1: Download Binary
-
Download the binary from the Releases page.
-
Run the tool:
./sql2er-exe test.sql -o erd.jpeg
Option 2: Build from Source
-
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
Option 3: Build WASM
- 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
Built With
<p align="right">(<a href="#readme-top">back to top</a>)</p>Roadmap
- [x] Add Changelog
- [x] Add Test Cases
- [x] Support
GENERATEDConstraint - [x] Gracefully Ignore Partitions
- [x] 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.
<p align="right">(<a href="#readme-top">back to top</a>)</p>Limitations
- 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.
Unsupported Features
DETACHUSING ...TABLESPACENOT VALIDVALIDATEINTERVALData Type
Acknowledgments
This project was inspired by sqldiagram, which focuses on MySQL but lacked robust parsing capabilities.
<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- MARKDOWN LINKS & IMAGES -->Related Skills
oracle
326.5kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
prose
326.5kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
Command Development
80.4kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
Plugin Structure
80.4kThis skill should be used when the user asks to "create a plugin", "scaffold a plugin", "understand plugin structure", "organize plugin components", "set up plugin.json", "use ${CLAUDE_PLUGIN_ROOT}", "add commands/agents/skills/hooks", "configure auto-discovery", or needs guidance on plugin directory layout, manifest configuration, component organization, file naming conventions, or Claude Code plugin architecture best practices.
