PostgreSQL to Mermaid ERD Generator

0.2.1 · active · verified Wed Apr 22

pg-mermaid is an open-source command-line interface (CLI) tool designed to generate Entity-Relationship Diagram (ERD) definitions in Mermaid syntax directly from a PostgreSQL database schema. Currently at version 0.2.1, it is explicitly marked as experimental and a work in progress, indicating an early stage of development with potential for frequent, unannounced changes and incomplete features. Its primary function is to simplify the visualization of database structures for documentation and communication, leveraging the human-readable Mermaid markdown language. Unlike general-purpose schema introspection tools, pg-mermaid focuses specifically on PostgreSQL and outputs a format readily renderable by Mermaid-compatible viewers and platforms. Given its early version, a stable release cadence is not yet established, and users should anticipate ongoing development rather than fixed schedules.

Common errors

Warnings

Install

Quickstart

Generates a Mermaid ERD markdown file for a PostgreSQL database, excluding specified tables.

PGPASSWORD="your_strong_password" npx pg-mermaid \
  --dbname mydatabase \
  --username myuser \
  --host localhost \
  --port 5432 \
  --schema public \
  --output-path ./mydatabase-erd.md \
  --excluded-tables audit_logs,temp_data \
  && echo "Mermaid ERD generated to mydatabase-erd.md"

view raw JSON →