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 🙏

© 2025 – Pkg Stats / Ryan Hefner

supabase-markdown

v1.0.4

Published

Generate beautiful Mermaid ERD diagrams and markdown documentation from your Supabase database.types.ts file

Readme

Supabase Markdown

npm version license downloads

Generate beautiful Mermaid ERD diagrams and markdown documentation from your Supabase database.types.ts file.

Installation

npm install -D supabase-markdown

pnpm add -D supabase-markdown

yarn add -D supabase-markdown

Features

  • 📊 Mermaid ERD Diagrams - Automatically generate visual database diagrams
  • 📚 Schema Documentation - Detailed markdown docs for all tables and relationships
  • 🎯 Multi-Schema Support - Works with multiple schemas (business, omx, public, etc.)
  • 🔄 Type-Safe - Parses TypeScript types directly from generated files
  • 🚀 Zero Config - Works out of the box with Supabase CLI generated types
  • 📋 Complete - Includes tables, columns, types, nullability, and relationships
  • 🔗 Enhanced FK Support - Optionally inspects database for system relationships (e.g. auth.users)

Example Output

Mermaid ERD Diagram

erDiagram
    ecommerce_orders {
        json details
        varchar created_at
        varchar id PK
        varchar user_id "NOT NULL"
    }
    ecommerce_products {
        varchar id PK
        varchar name "NOT NULL"
        varchar order_id "NOT NULL"
        varchar status
    }
    orders ||--o{ ecommerce_products : "order_id"

Schema Documentation

## Schema: `ecommerce`

### products

#### Columns

| Column   | Type   | Nullable |
| -------- | ------ | -------- |
| id       | string | ✗        |
| name     | string | ✗        |
| order_id | string | ✗        |
| status   | string | ✓        |

#### Relationships

| Foreign Key            | Column(s) | References | Type        |
| ---------------------- | --------- | ---------- | ----------- |
| products_order_id_fkey | order_id  | orders.id  | One-to-Many |

Enhanced Foreign Key Extraction

By default, supabase-markdown generates relationships solely from database.types.ts. However, some relationships (especially to system schemas like auth or cross-schema foreign keys) might be missing from the generated types.

To include these missing relationships, you can provide database credentials. The tool follows this priority:

  1. Direct Database Connection (Recommended)

    • Provides the most complete results, including auth, storage, and other system schemas.
    • usage: DATABASE_URL=postgres://... npx supabase-markdown
    • or flag: npx supabase-markdown --db-url "postgres://..."

    [!TIP] If you encounter ENOTFOUND or connection errors (common with IPv6-only databases on AWS), use the Transaction or Session pooler connection string instead of the direct connection string.

  2. Supabase API (Fallback)

    • Uses SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY.
    • Only finds relationships in exposed schemas (usually public).
    • Does NOT require a direct connection, but is less powerful.
  3. Manual Relations

    • Create a manualRelations.json file in your project root to manually define missing links.

Quick Start

1. Generate Database Types

First, generate your database.types.ts file using Supabase CLI:

# For local development
npx supabase gen types typescript --local > database.types.ts

# For production
npx supabase gen types typescript --project-id your-project-id > database.types.ts

2. Generate Documentation

# Generate to ./docs directory (default)
npx supabase-markdown

# Generate to custom directory
npx supabase-markdown --output ./documentation

# Use custom types file location
npx supabase-markdown --types-file ./src/types/database.types.ts

# Generate single combined file
npx supabase-markdown --output ./database-overview.md

3. View Your ERD

Open the generated ERD.md file in any markdown viewer that supports Mermaid diagrams (GitHub, VS Code, etc.)

Generated Files

After running the generator, you'll find:

  • ERD.md - Beautiful Mermaid ERD diagram showing all tables and relationships
  • database-schema.md - Detailed documentation of your database schema

Or a single combined file if you specified a .md output file.

Multi-Schema Support

supabase-markdown automatically detects and documents all schemas in your database:

export type Database = {
  public: { ... },
  business: { ... }
}

All schemas will be included in the generated ERD and documentation.

Requirements

  • Node.js 16+
  • A database.types.ts file generated by Supabase CLI

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Credits

Inspired by prisma-markdown by @samchon. This project adapts the concept of generating markdown documentation and ERD diagrams for Supabase databases.

License

MIT © Brandon Ha


Made with ❤️ for the Supabase community