npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

schemagraph

v1.4.4

Published

Zero-dependency pure Node.js CLI & library to parse schemas across any framework (Laravel, Django, Rails, Go, Spring JPA, Prisma, Mongoose, Sequelize, TypeORM, GraphQL, SQL) and generate responsive SVG ERDs, interactive HTML viewers, Mermaid markdown, DBM

Readme

⚡ schemagraph


⚡ Quick Start (Instant Run)

Run schemagraph directly in any project folder with npx — zero installation or setup needed:

npx schemagraph

[!TIP] 🚀 Zero Setup & Auto-Open: Automatically scans and parses your project's schemas, generates database-design.html + database-design.svg, and launches the interactive visual explorer in your default browser. (Pass --no-open to suppress in CI/CD).


📦 Installation Options

Choose how you prefer to run schemagraph:

# ⚡ Option 1: Instant Run with npx (Recommended — Zero install)
npx schemagraph

# 🌐 Option 2: Global CLI Install (Run `schemagraph` anywhere)
npm install -g schemagraph
schemagraph

# 🛠️ Option 3: Project Dev Dependency (For npm scripts & team workflows)
npm install --save-dev schemagraph

🎯 Individual Format Commands (Export On-Demand)

By default, schemagraph generates HTML + SVG. You can easily export to any specific format using --format:

# 🌐 1. Interactive HTML Explorer & SVG Diagram (Default)
npx schemagraph

# 📊 2. DBML Schema (Ready for dbdiagram.io & dbdocs.io)
npx schemagraph --format=dbml

# 🐬 3. Standard SQL DDL (Normalized CREATE TABLE & FOREIGN KEYs)
npx schemagraph --format=sql

# 🧜‍♂️ 4. Mermaid Markdown (For GitHub/GitLab READMEs)
npx schemagraph --format=md

# 🤖 5. Token-Optimized AI Prompt Context (For ChatGPT, Gemini, Claude, Cursor)
npx schemagraph --format=ai

# 📋 6. Machine-Readable JSON AST (For custom tooling & pipelines)
npx schemagraph --format=json

# 🕸 7. Graphviz DOT Digraph (For Graphviz / D3)
npx schemagraph --format=dot

# 📦 8. Export Multiple Formats to a Custom Directory
npx schemagraph ./backend --format=dbml,sql,ai,md --output=./docs

# 🚀 9. Export ALL Formats Simultaneously (Headless / CI Mode)
npx schemagraph ./ --format=all --output=./docs --no-open

🌟 Why schemagraph?

  • 🚫 Zero External Dependencies: Built strictly using pure Node.js standard library (fs, path, crypto, events, os). Under 40 KB install footprint. Zero supply-chain security risks.
  • ⚡ Instant Performance: Scans and parses 50+ models and generates all diagrams in under 50 milliseconds.
  • 🎯 Universal Multi-Framework Auto-Discovery: Automatically detects and parses:
    • 🐘 PHP / Laravel: Migration files (database/migrations/*.php with Schema::create, Blueprint, foreignId(), constrained()) and Eloquent models (belongsTo, hasMany).
    • 🐍 Python / Django & SQLAlchemy: Django models (models.Model, ForeignKey) and SQLAlchemy (Base, Column, ForeignKey).
    • 💎 Ruby on Rails: Schema (db/schema.rb, db/migrate/*.rb), create_table, add_foreign_key, and ActiveRecord models (belongs_to, has_many).
    • 🐹 Go / GORM: Structs with gorm:"primaryKey", gorm:"foreignKey", and relationship fields.
    • ☕ Java & Kotlin (Spring Boot): JPA / Hibernate @Entity, @Table, @Id, @Column, @ManyToOne, @JoinColumn.
    • ⚡ Node.js & TypeScript: Prisma (.prisma), Mongoose, Sequelize, TypeORM, GraphQL SDL (.graphql), TypeScript interfaces (interface User), Zod (z.object).
    • 🗄️ Relational SQL DDL: .sql files with CREATE TABLE, PRIMARY KEY, FOREIGN KEY ... REFERENCES for PostgreSQL, MySQL, SQLite, MariaDB.
  • 🎨 7 Output Formats:
    1. Responsive XML SVG: Modern dark & light developer themes (Catppuccin Mocha, Tokyo Dark, Slate Light), table cards, [PK] and [FK] badges, cubic bezier curves.
    2. Interactive Single-Page HTML Explorer: Standalone web app with draggable cards, smooth camera transitions, multi-color wire distinction, connection inspector, minimap, and in-browser exports.
    3. DBML (.dbml): Standard Database Markup Language compatible with dbdiagram.io and dbdocs.io.
    4. Normalized SQL DDL (.sql): Clean, standard SQL CREATE TABLE and constraint statements.
    5. Mermaid Markdown (.md): GitHub/GitLab native erDiagram block + formatted data dictionary tables ready for README.md.
    6. JSON Schema Map (.json): Machine-readable AST for CI/CD pipelines, documentation generators, or scripts.
    7. Graphviz DOT (.dot): Compatible with Graphviz graph engines (dot, neato, d3-graphviz).

📊 Live GitHub Mermaid ERD Demo

This diagram is rendered natively on GitHub using the Mermaid export produced by schemagraph:

erDiagram
    products ||--o{ categories : "category_id -> id"
    orders ||--o{ users : "user_id -> id"
    order_items ||--o{ orders : "order_id -> id"
    order_items ||--o{ products : "product_id -> id"
    reviews ||--o{ users : "user_id -> id"
    reviews ||--o{ products : "product_id -> id"

    users {
        SERIAL id PK
        VARCHAR_100_ name
        VARCHAR_255_ email
        VARCHAR_255_ password_hash
        VARCHAR_500_ avatar_url
        VARCHAR_20_ role
        TIMESTAMP created_at
    }
    categories {
        SERIAL id PK
        VARCHAR_100_ name
        VARCHAR_120_ slug
        TEXT description
    }
    products {
        SERIAL id PK
        INT category_id FK
        VARCHAR_200_ name
        VARCHAR_220_ slug
        DECIMAL_10__2_ price
        INT stock
        BOOLEAN is_active
        TIMESTAMP created_at
    }
    orders {
        SERIAL id PK
        INT user_id FK
        VARCHAR_50_ order_number
        DECIMAL_10__2_ total_amount
        VARCHAR_50_ status
        VARCHAR_50_ payment_status
        TEXT shipping_address
        TIMESTAMP created_at
    }
    order_items {
        SERIAL id PK
        INT order_id FK
        INT product_id FK
        INT quantity
        DECIMAL_10__2_ unit_price
    }
    reviews {
        SERIAL id PK
        INT user_id FK
        INT product_id FK
        INT rating
        TEXT comment
        TIMESTAMP created_at
    }

🌐 Interactive HTML Viewer Features

When you export with --format=html (or all), schemagraph produces a standalone, self-contained single-page web app with zero CDN dependencies (100% offline).

Key Features:

  • 🚀 Zero-Blur Pure Vector Engine: Crisp, sharp text and cards at any zoom level from 2% eagle-eye to 1000% ultra-close inspection.
  • 🎯 Smooth Animated Camera Navigation (easeOutCubic): Clicking 🎯 Focus Link or Center Table smoothly glides and zooms the camera to frame connected tables at the exact center of your screen.
  • 🌈 Multi-Color Wire Distinction: Relationship connectors use an 11-color deterministic palette so overlapping foreign keys are instantly distinguishable.
  • 💡 Single-Wire Persistent Spotlight: Clicking a relation locks in a 5.5px neon glow spotlight while dimming unrelated tables and edges.
  • 🖱️ Real-Time Draggable Table Cards: Reposition any table node freely; cubic Bézier connectors dynamically recalculate at 60fps.
  • 🔍 Docked Connection Inspector: Click any table or press [ to see all outgoing foreign keys and incoming referenced-by tables with cardinality badges.
  • 🗂️ Compact Mode for Large Schemas: Shrinks table cards to PK/FK keys only for high-density 50+ table architectures.
  • 🗺️ Interactive Minimap Radar: Eagle-eye minimap with click-to-jump radar view.
  • ⬇ 1-Click Multi-Format Export Dropdown: Download SVG, PNG, DBML, SQL, Mermaid Markdown, JSON, and DOT directly from the browser header.

💻 CLI Options Reference

schemagraph [targetDir] [options]

| Option | Flag | Default | Description | | :--- | :--- | :--- | :--- | | --format | -f | svg,html | Comma-separated: svg, html, md, json, dbml, dot, sql, ai, or all | | --output | -o | . | Target output directory for generated assets | | --theme | -t | catppuccin | Visual theme: catppuccin, dark, or light | | --title | | Database Schema Topology | Custom diagram header title | | --open | | true | Automatically open HTML viewer in default browser | | --no-open| | false | Disable automatic browser launch (useful for CI/CD) | | --exclude| -e | node_modules,.git,... | Comma-separated directories to ignore | | --help | -h | | Display help manual | | --version| -v | | Display version number |


🤖 AI & LLM Integration (ChatGPT, Gemini, Claude, Cursor)

schemagraph is designed from the ground up for modern AI coding agents and LLMs:

  1. llms.txt & llms-full.txt Native Support: Follows the llms.txt standard for automated package discovery and tool ingestion by LLMs.
  2. Instant AI Database Prompt: Run npx schemagraph --format=ai to produce a token-efficient architecture context file (database-schema-ai-prompt.md) ready to paste directly into ChatGPT, Gemini, Claude, or Cursor to ask complex questions about your database design, generate backend APIs, or plan SQL optimizations!
  3. 1-Click Copy in Browser: Click 🤖 Copy AI Schema Prompt inside the interactive HTML viewer to copy your complete database prompt directly to your clipboard.

📦 Programmatic Node.js API

Use schemagraph directly in your Node.js scripts, migration hooks, or build pipelines:

const {
    parseProject,
    generateSVG,
    generateHTML,
    generateMarkdown,
    generateJSON,
    generateDBML,
    generateDOT,
    generateSQL,
    generateAIContext
} = require('schemagraph');

// 1. Scan and parse workspace schema models
const schemaMap = parseProject('./backend');

// 2. Generate Interactive HTML Viewer
const html = generateHTML(schemaMap, {
    title: 'Database Explorer'
});

// 3. Generate SVG string
const svg = generateSVG(schemaMap, {
    theme: 'catppuccin', // 'catppuccin' | 'dark' | 'light'
    title: 'Application Architecture'
});

// 4. Generate DBML (for dbdiagram.io)
const dbml = generateDBML(schemaMap);

// 5. Generate Standard SQL DDL
const sql = generateSQL(schemaMap);

// 6. Generate Token-Optimized AI Context Prompt
const aiPrompt = generateAIContext(schemaMap);

// 7. Generate Mermaid Markdown
const markdown = generateMarkdown(schemaMap);

// 8. Generate JSON AST
const jsonAst = generateJSON(schemaMap);

🎨 Built-in Themes

| Theme | Identifier | Description | | :--- | :--- | :--- | | Catppuccin Mocha | catppuccin (default) | Soothing dark pastel palette with glowing accent connector lines. | | Tokyo Dark | dark | Deep slate blue background with electric blue headers and pink relationship lines. | | Slate Light | light | High-contrast clean indigo palette designed for print, PDFs, and light wikis. |


🤖 Continuous Integration & Automation Recipes

Auto-generate ERD on Git Commit (Husky)

Add to your package.json scripts to keep docs in sync with your migrations automatically:

{
  "scripts": {
    "docs:db": "schemagraph ./backend --format=all --output=./docs --no-open"
  }
}

GitHub Actions Workflow

Automatically regenerate and commit updated diagrams when schema files change:

name: Generate Database ERD
on:
  push:
    paths:
      - 'database/migrations/**'
      - 'prisma/**'
      - 'models/**'
      - 'migrations/**'

jobs:
  build-docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npx schemagraph ./ --format=all --output=./docs --no-open
      - name: Commit updated ERD
        run: |
          git config --global user.name "github-actions[bot]"
          git config --global user.email "github-actions[bot]@users.noreply.github.com"
          git add docs/
          git commit -m "docs(db): update database architecture diagrams [skip ci]" || exit 0
          git push

🥊 Comparison with Other Tools

| Feature | schemagraph | prisma-erd-generator | dbdocs / dbml-cli | Graphviz (dot) | | :--- | :---: | :---: | :---: | :---: | | External Dependencies | 0 (Zero) | 15+ npm packages | 20+ npm packages | Requires C++ Binary | | Universal Multi-Framework Support | Laravel, Django, Rails, Go, Spring, Prisma, Mongoose, Sequelize, TypeORM, GraphQL, SQL | Prisma Only | DBML Only | DOT only | | Output Formats | 7 Formats (SVG, HTML, MD, JSON, DBML, DOT, SQL) | SVG / PNG | Web / DBML | SVG / PNG | | Interactive HTML App | Yes (Zero-blur, 60fps Animation, Minimap) | No | Web Hosted | No | | In-Browser Multi-Format Download | Yes (1-Click SVG/PNG/DBML/SQL/MD/JSON/DOT) | No | No | No | | Execution Speed | < 50ms | ~2000ms | ~1500ms | ~800ms | | Offline / Air-gapped | 100% Offline | Partial | Needs Internet | Offline |


❓ Frequently Asked Questions (FAQ)

Simply navigate to your Prisma project root and run:

npx schemagraph

schemagraph has zero external dependencies and directly parses .prisma files without needing Graphviz C++ libraries or Python runtimes.

Yes! Run npx schemagraph ./database/migrations. schemagraph natively parses Schema::create, Blueprint, foreignId(), and constrained() methods to map the entire relational architecture automatically.

Run:

npx schemagraph --format=dbml

This generates database-design.dbml which you can paste directly into dbdiagram.io.

Run:

npx schemagraph --format=ai

Or click 🤖 Copy AI Schema Prompt in the interactive HTML viewer to copy a token-optimized database context directly to your clipboard.

Yes. schemagraph uses pure Node.js standard libraries (fs, path, crypto). The generated HTML viewer is 100% self-contained with no external CDN or web fonts required.


📄 License

MIT License © 2026 Shailesh Thakor