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

salesforce-erd-generator

v1.0.1

Published

Generate interactive Entity Relationship Diagrams and comprehensive metadata documentation for Salesforce objects

Readme

📊 Salesforce ERD Generator

A powerful command-line tool that generates interactive Entity Relationship Diagrams (ERD) and comprehensive metadata documentation for Salesforce objects.

Version License Node

✨ Features

  • 🎨 Visual ERD Diagrams - Generate beautiful SVG entity relationship diagrams
  • 📋 CSV Metadata Export - Complete field-level documentation in CSV format
  • 🔍 SOQL Query Generation - Auto-generated, formatted SOQL queries for each object
  • 🌐 Interactive Dashboard - Dark-themed HTML dashboard with:
    • Zoomable SVG viewer with pan controls
    • Searchable and sortable metadata table
    • Syntax-highlighted SOQL editor
    • Responsive design for all screen sizes
  • 🚀 Auto-open in Browser - Dashboard opens automatically after generation

Screenshots

  • ERD
  • Schema
  • SOQL

📦 Installation

Global Installation (Recommended)

npm install -g salesforce-erd-generator

Prerequisites

  • Node.js >= 14.0.0
  • Salesforce CLI (sf) with mohanc plugin installed
    • install mohanc plugin:
    sf plugins install sfdx-mohanc-plugins
  • Valid Salesforce org credentials configured

🚀 Quick Start

Basic Usage

sf-erd -o [email protected] -s Account,Contact,Opportunity

This will generate:

  • Account-Contact-Opportunity.svg - Combined ERD diagram
  • Account-Contact-Opportunity.csv - All metadata in CSV format
  • Account-Contact-Opportunity.soql - SOQL queries for all objects
  • Account-Contact-Opportunity.html - Interactive dashboard (auto-opens)

Using Alias

sf-erd -o myDevOrg -s Account,Contact

Single Object

sf-erd -o username -s Account

📖 Command-Line Options

| Option | Alias | Description | Required | |--------|-------|-------------|----------| | -o <username> | --org | Salesforce org username or alias | ✅ Yes | | -s <objects> | --sobjects | Comma-separated list of Salesforce objects | ✅ Yes |

📂 Output Files

1. SVG Diagram (*.svg)

  • Visual representation of object schemas
  • Shows relationships between objects
  • Includes all fields with data types
  • Can be opened in any browser or SVG viewer

2. CSV Metadata (*.csv)

  • Complete field metadata for all objects
  • Includes: field name, type, length, nullable, references, etc.
  • Import into Excel, Google Sheets, or any CSV tool

3. SOQL Queries (*.soql)

  • Pre-formatted SELECT statements for each object
  • Fields organized 3 per line for readability
  • Ready to copy-paste into Developer Console or Workbench

4. Interactive Dashboard (*.html)

  • SVG Tab:
    • Zoom in/out controls
    • Fit to width
    • Pan and scroll
    • Download SVG button
  • CSV Tab:
    • Search across all fields
    • Sort by any column
    • Pagination (10/25/50/100 entries)
    • Responsive table
  • SOQL Tab:
    • Syntax-highlighted editor
    • Edit and save queries
    • Dark theme for comfortable viewing

🎨 Dashboard Features

SVG Viewer

🔍 Zoom In/Out | ↺ Reset | ↔ Fit Width | ⬇ Download

Metadata Table

  • Search: Real-time filtering across all columns
  • Sort: Click any column header to sort
  • Pagination: Navigate through large datasets
  • Responsive: Adapts to screen size

SOQL Editor

  • Monaco Editor (VS Code engine)
  • SQL syntax highlighting
  • Dark theme
  • Save edited queries

💡 Usage Examples

Example 1: Standard Objects

sf-erd -o production -s Account,Contact,Lead,Opportunity

Example 2: Custom Objects

sf-erd -o sandbox -s CustomObject__c,AnotherCustom__c

Example 3: Mixed Objects

sf-erd -o myorg -s Account,Contact,CustomProduct__c,Invoice__c

Example 4: Large Schema

sf-erd -o enterprise -s Account,Contact,Lead,Opportunity,Case,Campaign,Product2,PricebookEntry

🛠️ Technical Details

Dependencies

  • Salesforce CLI - For org access and metadata retrieval
  • mohanc plugin - For metadata describe functionality

Generated Files Structure

.
├── <objects>.svg          # SVG diagram
├── <objects>.csv          # Metadata CSV
├── <objects>.soql         # SOQL queries
└── <objects>.html         # Interactive dashboard

SOQL Format

Queries are formatted for maximum readability:

SELECT
    Id, Name, Type,
    BillingStreet, BillingCity, BillingState,
    Phone, Fax, Website
FROM Account

🎯 Use Cases

  • Documentation: Generate comprehensive schema documentation
  • Training: Visual aids for team onboarding
  • Analysis: Understand object relationships and dependencies
  • Development: Reference for building integrations
  • Migration: Plan data migration strategies
  • Auditing: Review field configurations and settings

🐛 Troubleshooting

"sf CLI not found"

# Install Salesforce CLI
npm install -g @salesforce/cli

"mohanc plugin not found"

# Install mohanc plugin
sf plugins install sfdx-mohanc-plugins

"Org not authenticated"

# Authenticate to your org
sf org login web -a myorg

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built on top of Salesforce CLI
  • Uses mohanc plugin (sf plugins install sfdx-mohanc-plugins)
  • Monaco Editor for SOQL syntax highlighting

🗺️ Roadmap

  • [ ] Export to PNG/PDF
  • [ ] Compare schemas between orgs
  • [ ] Support for platform events and big objects
  • [ ] Field usage analytics
  • [ ] Dependency graph visualization
  • [ ] Custom color themes
  • [ ] Multi-language support

Made with ❤️ for the Salesforce Community

⭐ Star this repo if you find it useful!