SkillAgentSearch skills...

Sql2er

Generate ER-diagram using SQL file

Install / Use

/learn @tusharad/Sql2er
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Contributors
Forks
Stargazers
Issues
MIT License
LinkedIn

<!-- PROJECT LOGO --> <div align="center" id="readme-top"> <a href="https://github.com/tusharad/sql2er"> <img src="example/logo.jpeg" alt="Logo" width="180" height="180"> </a> <h1 align="center">SQL 2 ER</h1> <p align="center"> A command-line tool to convert SQL scripts into Entity-Relationship (ER) diagrams. <br> Designed to work with PostgreSQL syntax. <br> <a href="https://github.com/tusharad/sql2er/issues/new?labels=bug&template=bug-report---.md"><strong>Report a Bug</strong></a> · <a href="https://github.com/tusharad/sql2er/issues/new?labels=enhancement&template=feature-request---.md"><strong>Request a Feature</strong></a> </p> </div>

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

  1. Download the binary from the Releases page.

  2. Run the tool:

    ./sql2er-exe test.sql -o erd.jpeg
    

Option 2: Build from Source

  1. Install Stack via GHCup.

  2. Clone the repository and navigate to the project root.

  3. 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

  1. Install wasm32-wasi-cabal from here
  2. Make sure to download the 9.8 FLAVOUR.
wasm32-wasi-cabal build sql2er-wasm -f build-sql2er-wasm
cp path/to/sql2er-wasm.wasm .
python3 -m http.server

Built With

Haskell

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Roadmap

  • [x] Add Changelog
  • [x] Add Test Cases
  • [x] Support GENERATED Constraint
  • [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.
<p align="right">(<a href="#readme-top">back to top</a>)</p>

Unsupported Features

  • DETACH
  • USING ...
  • TABLESPACE
  • NOT VALID
  • VALIDATE
  • INTERVAL Data Type
<p align="right">(<a href="#readme-top">back to top</a>)</p>

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

View on GitHub
GitHub Stars17
CategoryData
Updated2mo ago
Forks0

Languages

Haskell

Security Score

95/100

Audited on Jan 12, 2026

No findings