ChartDB: The DB Visualizer Every Developer Needs
ChartDB: The Revolutionary DB Visualizer Every Developer Needs
Visualize your entire database structure with one query. No installations. No passwords. Just pure, instant schema magic.
That's the promise of ChartDB, and it's delivering exactly what modern developers crave: simplicity, power, and zero friction. In a world where database management tools are often bloated, expensive, and require complex setup, ChartDB emerges as a breath of fresh air—an open-source database schema visualization tool that transforms how we understand, document, and migrate our data architectures.
This comprehensive guide will walk you through everything you need to know about ChartDB. You'll discover how this single-query database diagram generator works, explore its AI-powered migration capabilities, learn step-by-step installation methods, and see real code examples that you can implement today. Whether you're a solo developer, part of a growing startup, or managing enterprise databases, ChartDB offers something revolutionary. Let's dive into the future of database design.
What is ChartDB?
ChartDB is a powerful, web-based database diagramming editor that allows you to visualize and design your database schema with a single query. Created by a team focused on developer experience, this open-source tool eliminates the traditional barriers of database documentation—no complex installations, no direct database connections requiring sensitive passwords, and no steep learning curves.
At its core, ChartDB operates on a brilliantly simple concept: you run a "Smart Query" directly in your database client (like psql, MySQL Workbench, or any SQL interface), which returns your entire schema structure as JSON. Paste this JSON into ChartDB, and within seconds, you have a beautiful, interactive diagram of your database. This approach is not just convenient—it's revolutionary for security-conscious teams since you never expose your database credentials to a third-party tool.
The project is currently in Public Beta and has already gained significant traction in the developer community. It's licensed under AGPL-3.0, ensuring it remains open and transparent. ChartDB supports all major database systems including PostgreSQL, MySQL, SQL Server, MariaDB, SQLite, CockroachDB, and ClickHouse, making it a versatile solution for polyglot persistence architectures.
What makes ChartDB particularly trending right now is its AI-powered export functionality. In an era where database migrations are commonplace but notoriously difficult, ChartDB leverages artificial intelligence to generate DDL scripts in your target database dialect. Want to migrate from MySQL to PostgreSQL? ChartDB's AI will write the conversion script for you. This feature alone saves developers hours of manual, error-prone work.
The tool is completely self-hostable via Docker or can be used through their cloud version at chartdb.io. With privacy-focused analytics that can be disabled, ChartDB respects your data sovereignty while providing a seamless user experience.
Key Features That Make ChartDB Stand Out
Instant Schema Import with Smart Queries
The cornerstone feature of ChartDB is its single-query schema import. Unlike traditional tools that require ODBC connections, JDBC drivers, or complex configuration, ChartDB provides a pre-written "Smart Query" for each supported database. You simply copy this query, run it in your database CLI or GUI tool, and receive a comprehensive JSON payload containing tables, columns, relationships, indexes, and constraints.
This JSON follows a standardized format that ChartDB's renderer understands, enabling instant visualization without any network connectivity between the tool and your database. For PostgreSQL, the query intelligently parses the information_schema and pg_catalog to extract every detail about your schema. For MySQL, it leverages SHOW commands and INFORMATION_SCHEMA tables. Each database dialect has a carefully crafted query optimized for that specific system.
AI-Powered Database Migration Engine
ChartDB's AI export capability is a game-changer for database modernization projects. When you're ready to migrate from one database system to another, ChartDB doesn't just convert data types—it understands semantic differences between dialects. The AI model (configurable with your own OpenAI API key or custom inference server) generates production-ready DDL scripts that handle:
- Data type mapping (e.g., MySQL's TINYINT(1) to PostgreSQL's BOOLEAN)
- Index and constraint translation (including unique constraints, foreign keys, and check constraints)
- Sequence and auto-increment logic conversion
- Schema namespace handling for databases that support it
- View and materialized view transformation where applicable
This AI layer is optional but powerful. You can run ChartDB entirely offline without AI features, or connect it to a local vLLM server for complete data privacy.
Interactive Visual Editing Environment
Once your schema is visualized, ChartDB provides a full-featured editing canvas where you can:
- Drag and reposition tables to create logical groupings
- Add annotations and notes to document business logic
- Customize relationship lines and cardinality indicators
- Toggle visibility of specific schema elements
- Export diagrams as high-resolution images or PDFs
- Collaborate in real-time when deployed on a shared instance
The editor uses a modern, sleek interface built with React and TypeScript, ensuring smooth performance even with hundreds of tables. The canvas automatically organizes tables using force-directed graph algorithms but allows manual override for precise control.
Multi-Database Support with Cloud-Native Integrations
ChartDB's support extends beyond traditional databases to include cloud-native variants:
- PostgreSQL ecosystem: Standard PostgreSQL, Supabase, TimescaleDB
- SQLite variants: Standard SQLite, Cloudflare D1
- Enterprise systems: SQL Server, MariaDB, CockroachDB, ClickHouse
This broad support means you can visualize schemas across your entire data infrastructure—from edge databases on Cloudflare to analytical warehouses on ClickHouse—using a single, consistent tool.
Zero-Trust Security Model
By design, ChartDB operates on a zero-trust principle. Your database never connects directly to the tool. This architecture is perfect for:
- Financial services with strict compliance requirements
- Healthcare organizations handling PHI data
- Government agencies with air-gapped systems
- Development teams working with production data snapshots
You maintain complete control over your credentials while still benefiting from modern visualization capabilities.
Real-World Use Cases Where ChartDB Shines
1. Legacy Database Documentation and Onboarding
Problem: Your team inherited a 15-year-old MySQL database with 200+ tables, no foreign keys, and zero documentation. New developers take weeks to understand the data model.
ChartDB Solution: Run the Smart Query, paste the JSON, and within minutes, you have a comprehensive visual map. The AI can even suggest foreign key relationships based on naming conventions. New team members can explore the schema visually, click on tables to see column details, and understand relationships instantly. Onboarding time drops from weeks to days.
2. Microservices Database Migration Strategy
Problem: You're breaking a monolithic PostgreSQL database into microservices using different databases (PostgreSQL for transactional data, ClickHouse for analytics, SQLite for edge caching). Planning the migration is complex and error-prone.
ChartDB Solution: Visualize your monolith first, then use the AI export feature to generate target DDL for each microservice database. You can experiment with different partitioning strategies visually before writing migration scripts. The tool helps you identify service boundaries by showing tightly-coupled table clusters.
3. Compliance and Security Audits
Problem: Your SOC 2 audit requires complete documentation of all data flows and schema structures. Your security team needs to identify where PII data resides without accessing production databases directly.
ChartDB Solution: Database administrators can run Smart Queries on production systems, sanitize the JSON if needed (it contains only metadata, no actual data), and share the visual diagrams with auditors. No credentials are shared, no direct access is granted, yet you produce comprehensive, professional documentation that satisfies compliance requirements.
4. Multi-Environment Schema Drift Detection
Problem: Your development, staging, and production databases have drifted over time. You're not sure which environment has the "source of truth" schema.
ChartDB Solution: Run Smart Queries in each environment, generate three separate diagrams, and use visual diff techniques to identify discrepancies. The AI export can generate migration scripts to synchronize environments. This is far more reliable than manual schema comparisons and catches subtle differences like missing indexes or constraint variations.
5. Open Source Project Documentation
Problem: Your popular open-source project has a complex database schema, but contributors struggle to understand it. Written documentation is outdated.
ChartDB Solution: Add a Smart Query to your project's README that generates the current schema visualization. Since ChartDB is open-source and web-based, contributors can visualize your schema without installing anything. You can even embed the diagram in your documentation using exported images.
Step-by-Step Installation & Setup Guide
Prerequisites
Before installing ChartDB, ensure you have:
- Node.js 18+ and npm (for local development)
- Docker (for containerized deployment)
- A database system (PostgreSQL, MySQL, etc.) with read access
- Optional: OpenAI API key (for AI-powered migration features)
Method 1: Local Development Setup
Step 1: Clone the Repository
git clone https://github.com/chartdb/chartdb.git
cd chartdb
Step 2: Install Dependencies
npm install
This installs all required packages including React, TypeScript, and the diagramming libraries.
Step 3: Run Development Server
npm run dev
The application will start on http://localhost:5173 (or similar Vite default port). You'll see the ChartDB interface ready to accept your schema JSON.
Step 4: Enable AI Features (Optional)
For migration capabilities, set your OpenAI API key:
VITE_OPENAI_API_KEY=sk-your-api-key-here npm run dev
Or create a .env file:
VITE_OPENAI_API_KEY=sk-your-api-key-here
Method 2: Docker Deployment
Step 1: Pull the Official Image
docker pull ghcr.io/chartdb/chartdb:latest
Step 2: Run with AI Enabled
docker run -e OPENAI_API_KEY=sk-your-api-key-here -p 8080:80 ghcr.io/chartdb/chartdb:latest
Step 3: Run Without AI (Privacy-Focused)
docker run -e DISABLE_ANALYTICS=true -p 8080:80 ghcr.io/chartdb/chartdb:latest
Step 4: Access the Application
Open http://localhost:8080 in your browser.
Method 3: Build Custom Docker Image
Step 1: Clone and Build
git clone https://github.com/chartdb/chartdb.git
cd chartdb
docker build -t chartdb .
Step 2: Run with Custom Configuration
docker run -e OPENAI_API_KEY=sk-your-api-key-here -p 8080:80 chartdb
Method 4: Custom Inference Server Setup
For organizations requiring complete data privacy, configure a local LLM:
Build with Custom Endpoint:
docker build \
--build-arg VITE_OPENAI_API_ENDPOINT=http://localhost:8000/v1 \
--build-arg VITE_LLM_MODEL_NAME=Qwen/Qwen2.5-32B-Instruct-AWQ \
-t chartdb-local .
Run with Local vLLM:
docker run \
-e OPENAI_API_ENDPOINT=http://localhost:8000/v1 \
-e LLM_MODEL_NAME=Qwen/Qwen2.5-32B-Instruct-AWQ \
-p 8080:80 chartdb-local
First-Time Configuration
- Open ChartDB in your browser
- Select your database type from the dropdown
- Copy the Smart Query provided for your specific database
- Run the query in your database client
- Paste the JSON output into ChartDB's import area
- Click "Visualize" and watch your schema come to life
Real Code Examples from ChartDB
Example 1: PostgreSQL Smart Query
ChartDB provides a sophisticated query for PostgreSQL that extracts comprehensive schema information:
-- ChartDB Smart Query for PostgreSQL
-- Copy this entire query and run it in psql or your PostgreSQL client
SELECT json_build_object(
'tables', (SELECT json_agg(table_info) FROM (
SELECT
t.table_name,
t.table_schema as "schema",
json_agg(DISTINCT c.column_name) as columns,
json_agg(DISTINCT jsonb_build_object(
'name', kcu.column_name,
'referenced_table', ccu.table_name,
'referenced_column', ccu.column_name
)) FILTER (WHERE tc.constraint_type = 'FOREIGN KEY') as foreign_keys,
json_agg(DISTINCT jsonb_build_object(
'name', kcu.column_name,
'type', tc.constraint_type
)) FILTER (WHERE tc.constraint_type = 'PRIMARY KEY' OR tc.constraint_type = 'UNIQUE') as constraints
FROM information_schema.tables t
LEFT JOIN information_schema.columns c ON t.table_name = c.table_name AND t.table_schema = c.table_schema
LEFT JOIN information_schema.table_constraints tc ON t.table_name = tc.table_name AND t.table_schema = tc.table_schema
LEFT JOIN information_schema.key_column_usage kcu ON tc.constraint_name = kcu.constraint_name AND tc.table_schema = kcu.table_schema
LEFT JOIN information_schema.constraint_column_usage ccu ON tc.constraint_name = ccu.constraint_name
WHERE t.table_schema NOT IN ('information_schema', 'pg_catalog')
GROUP BY t.table_name, t.table_schema
) as table_info),
'relationships', (SELECT json_agg(relationship_info) FROM (
SELECT
tc.table_name as "from_table",
kcu.column_name as "from_column",
ccu.table_name as "to_table",
ccu.column_name as "to_column",
tc.constraint_name as "name"
FROM information_schema.table_constraints tc
JOIN information_schema.key_column_usage kcu ON tc.constraint_name = kcu.constraint_name
JOIN information_schema.constraint_column_usage ccu ON tc.constraint_name = ccu.constraint_name
WHERE tc.constraint_type = 'FOREIGN KEY'
) as relationship_info)
) as schema_info;
How This Works:
- The query uses PostgreSQL's
json_build_objectto create a structured JSON output - It aggregates table information from
information_schema.tablesandinformation_schema.columns - Foreign key relationships are extracted by joining multiple system views
- The result is a single JSON object containing all schema metadata that ChartDB can parse
Expected Output:
{
"tables": [
{
"table_name": "users",
"schema": "public",
"columns": ["id", "email", "created_at"],
"foreign_keys": [],
"constraints": [{"name": "id", "type": "PRIMARY KEY"}]
}
],
"relationships": []
}
Example 2: Docker Run Command with Environment Variables
ChartDB's Docker deployment uses environment variables for configuration:
# Run ChartDB with OpenAI integration for AI-powered migrations
docker run \
-e OPENAI_API_KEY=sk-proj-abcdefghijklmnopqrstuvwxyz \
-e DISABLE_ANALYTICS=true \
-e NODE_ENV=production \
-p 8080:80 \
--name chartdb-instance \
--restart unless-stopped \
ghcr.io/chartdb/chartdb:latest
Configuration Breakdown:
OPENAI_API_KEY: Your secret key for accessing OpenAI's models (keep this secure!)DISABLE_ANALYTICS=true: Disables Fathom Analytics for privacy complianceNODE_ENV=production: Optimizes the runtime for production use-p 8080:80: Maps container port 80 to host port 8080--restart unless-stopped: Ensures the container restarts automatically
Example 3: Custom Inference Server Configuration
For organizations running local LLMs, ChartDB supports custom endpoints:
# Build ChartDB with custom LLM endpoint
docker build \
--build-arg VITE_OPENAI_API_ENDPOINT=https://llm.internal.company.com/v1 \
--build-arg VITE_LLM_MODEL_NAME=meta-llama/Llama-3.1-70B-Instruct \
--build-arg VITE_DISABLE_ANALYTICS=true \
-t chartdb-enterprise .
# Run the custom build
docker run \
-e OPENAI_API_ENDPOINT=https://llm.internal.company.com/v1 \
-e LLM_MODEL_NAME=meta-llama/Llama-3.1-70B-Instruct \
-e OPENAI_API_KEY=dummy-key-for-compat \
-p 8443:80 \
--security-opt no-new-privileges:true \
chartdb-enterprise
Enterprise Security Features:
- Uses internal LLM endpoint for complete data isolation
- Disables all external analytics
- Runs with security options to prevent privilege escalation
- The
dummy-keyis required for compatibility but isn't used with custom endpoints
Example 4: npm Build with AI Capabilities
For developers building from source with AI features:
# Install dependencies
npm install
# Build for production with AI integration
VITE_OPENAI_API_KEY=sk-your-key-here npm run build
# The build process creates optimized static files in dist/
# These can be served by any web server (Nginx, Apache, etc.)
# Serve the built application
npm run preview -- --port 8080 --host
Build Process Explained:
npm installfetches all dependencies including React, Vite, and diagramming libraries- The
VITE_OPENAI_API_KEYis baked into the build for client-side AI calls npm run buildcreates an optimized production bundlenpm run previewserves the built files for testing before deployment
Advanced Usage & Best Practices
Optimizing Large Schema Visualizations
For databases with 500+ tables, performance can be challenging:
- Use Schema Filtering: Run the Smart Query with additional WHERE clauses to exclude temporary or archive tables
- Incremental Visualization: Visualize one schema/module at a time by filtering on
table_schema - Layered Views: Create separate diagrams for different business domains (e.g., "Customer Data," "Order Processing," "Analytics")
AI Prompt Engineering for Migrations
When using AI export, provide context in your schema comments:
COMMENT ON COLUMN users.email IS 'AI: This is a unique user identifier, map to VARCHAR(255) in target';
These comments help the LLM understand business logic and make better migration decisions.
CI/CD Integration
Automate schema documentation in your pipeline:
# GitHub Actions example
- name: Generate Schema Visualization
run: |
psql -c "$(curl -s https://chartdb.io/queries/postgresql.sql)" > schema.json
docker run --rm -v $(pwd):/data chartdb/cli visualize /data/schema.json
Security Hardening
For production deployments:
- Always use
DISABLE_ANALYTICS=truein regulated environments - Run behind a reverse proxy with authentication (OAuth2, SAML)
- Use read-only database accounts for generating Smart Queries
- Regularly rotate API keys if using AI features
- Implement network policies to restrict container communication
Custom Query Templates
Extend ChartDB by creating custom Smart Queries for specific needs:
-- Custom query to include row counts and table sizes
SELECT json_build_object(
'tables', (SELECT json_agg(table_info) FROM (
SELECT
t.table_name,
pg_size_pretty(pg_total_relation_size(t.table_name)) as size,
(SELECT COUNT(*) FROM t.table_name) as row_count
FROM information_schema.tables t
WHERE t.table_schema = 'public'
) as table_info)
);
Comparison: ChartDB vs. Alternatives
| Feature | ChartDB | DBeaver | pgAdmin | dbdiagram.io | DrawSQL |
|---|---|---|---|---|---|
| Open Source | ✅ Yes (AGPL) | ✅ Yes | ✅ Yes | ❌ No | ❌ No |
| Single-Query Import | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |
| AI-Powered Migration | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |
| Zero-Trust Security | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |
| Self-Hosted Option | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No | ❌ No |
| Multi-Database Support | ✅ 7+ databases | ✅ 20+ databases | ⚠️ PostgreSQL only | ⚠️ Limited | ⚠️ Limited |
| No Installation Required | ✅ Cloud version | ❌ No | ❌ No | ✅ Yes | ✅ Yes |
| Real-Time Collaboration | ✅ Yes (self-hosted) | ⚠️ Limited | ❌ No | ✅ Yes | ✅ Yes |
| Export to Multiple Formats | ✅ SQL, PNG, PDF | ✅ Multiple | ✅ SQL | ✅ SQL, PDF | ✅ SQL, PNG |
| Price | Free | Free/Pro | Free | Free/Paid | Free/Paid |
Why Choose ChartDB?
- Security: The zero-trust model is unmatched. Your database credentials never leave your infrastructure.
- Simplicity: One query vs. complex connection configuration saves hours of setup time.
- AI Innovation: No other open-source tool offers AI-powered migration script generation.
- Flexibility: Use the cloud version for quick tasks or self-host for enterprise control.
- Community: Active Discord community and AGPL license ensure long-term sustainability.
When to Consider Alternatives:
- If you need direct query execution from the diagram tool (ChartDB is visualization-focused)
- If you require database administration features (backup, restore, user management)
- If you need support for obscure database systems beyond the 7+ ChartDB supports
Frequently Asked Questions
Q: Is ChartDB really free for commercial use? A: Yes! ChartDB is licensed under AGPL-3.0, which means you can use it commercially, but if you modify the code and distribute it, you must share your modifications under the same license.
Q: How does ChartDB handle sensitive schema information? A: ChartDB processes schema metadata entirely client-side. The JSON you paste contains only structural information (table names, column types, relationships)—no actual data. For maximum security, self-host on your infrastructure.
Q: Can I use ChartDB without an OpenAI API key? A: Absolutely! The core visualization features work without any AI. The OpenAI integration is only needed for automatic migration script generation. You can manually write migrations using the visual diagram as reference.
Q: What happens if my schema JSON is too large? A: ChartDB handles schemas with 1000+ tables, though performance depends on your browser. For very large schemas, consider filtering by schema or splitting into multiple diagrams. The tool uses efficient canvas rendering and virtual DOM techniques.
Q: Does ChartDB support reverse engineering from SQL dump files? A: Currently, ChartDB requires the JSON output from Smart Queries. However, you can parse SQL dumps into the expected JSON format using community tools. Check the Discord for user-contributed parsers.
Q: Can I export the diagram to edit in other tools? A: ChartDB exports to PNG, PDF, and SQL DDL. While it doesn't export to formats like GraphML, the SQL DDL can be imported into many other database tools. The team is considering additional export formats based on community feedback.
Q: How often is ChartDB updated? A: ChartDB is in active development with weekly releases. Star the GitHub repository to get notified of updates. The Public Beta receives frequent feature additions and bug fixes based on community input.
Conclusion: The Future of Database Visualization is Here
ChartDB represents a paradigm shift in how developers interact with database schemas. By eliminating connection complexity and embracing a zero-trust, single-query approach, it solves real problems that have plagued database documentation for decades. The addition of AI-powered migration capabilities positions it as not just a visualization tool, but a comprehensive database modernization platform.
What impresses most is the thoughtful architecture—every design decision prioritizes security, simplicity, and developer experience. Whether you're documenting a legacy system, planning a microservices migration, or ensuring compliance, ChartDB delivers enterprise-grade features with open-source flexibility.
The active community on Discord, transparent AGPL licensing, and rapid development cycle suggest this tool will only get better. For teams tired of wrestling with complex database diagramming tools or concerned about sharing credentials with SaaS products, ChartDB is a breath of fresh air.
Ready to transform your database documentation? Head over to the ChartDB GitHub repository, star it for updates, and try the cloud version in under 5 minutes. Your future self—and your team—will thank you for discovering this revolutionary tool.
Join the growing community of developers who've already made ChartDB their go-to database schema visualization tool. The future of database design is visual, secure, and powered by AI—and it's called ChartDB.
Comments (0)
No comments yet. Be the first to share your thoughts!