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

sqlite-visualizer

v1.0.7

Published

React library for visualizing SQLite databases in the browser with ER diagrams, query builder, data explorer, and query plan visualization

Readme

🗄️ SQLite Visualizer

A powerful React library for visualizing SQLite databases directly in the browser

npm version npm downloads License: MIT TypeScript

FeaturesInstallationQuick StartDocumentationDemo


📋 Table of Contents


🎯 Problem & Solution

The Problem

Working with SQLite databases in web applications has always been challenging:

  • ❌ No native browser support for SQLite
  • ❌ Difficult to visualize database schemas and relationships
  • ❌ Lack of intuitive query building tools
  • ❌ No easy way to explore data without backend infrastructure
  • ❌ Query optimization requires external tools

The Solution

SQLite Visualizer brings the full power of SQLite to your React applications:

  • 100% Browser-Based: Uses sql.js (WebAssembly) - no server required
  • Visual ER Diagrams: Interactive schema visualization with relationships
  • Query Builder: Intuitive SQL editor with autocomplete
  • Data Explorer: Browse tables with filtering, sorting, and pagination
  • Query Plan Analyzer: Visualize execution plans for optimization
  • Developer-Friendly: Hotkeys, history, sharing, and more

✨ Features

🎨 Core Components

  • SQLiteViewer - Interactive ER diagram with zoom, pan, and table selection
  • QueryBuilder - SQL editor with autocomplete, syntax highlighting, and execution
  • DataExplorer - Table viewer with advanced filtering, sorting, and pagination
  • QueryPlan - Visual query plan analyzer with tree and table views

🚀 Advanced Features

  • Database Management: Load .db files or create databases from scratch
  • Export Options: Export to SQL, JSON, or CSV formats
  • Query History: Track all executed queries with performance metrics
  • SQL Autocomplete: Intelligent suggestions based on schema
  • Hotkeys: DBeaver-like keyboard shortcuts for power users
  • Query Sharing: Generate shareable links for queries
  • Migration Support: Create and manage database migrations

🎯 Developer Experience

  • TypeScript: Full type safety and IntelliSense support
  • Tree-Shaking: Optimized bundle size
  • Styled Components: Customizable theming
  • Zero Dependencies: Only React and sql.js required

📦 Installation

npm install sqlite-visualizer
# or
yarn add sqlite-visualizer
# or
pnpm add sqlite-visualizer

Peer Dependencies

npm install react react-dom styled-components

🚀 Quick Start

1. Wrap your app with SQLiteProvider

import { SQLiteProvider } from 'sqlite-visualizer';

function App() {
  return (
    <SQLiteProvider>
      <YourApp />
    </SQLiteProvider>
  );
}

2. Use the components

import { SQLiteViewer, QueryBuilder, DataExplorer } from 'sqlite-visualizer';

function DatabaseDashboard() {
  return (
    <div>
      <SQLiteViewer width={800} height={600} />
      <QueryBuilder />
      <DataExplorer />
    </div>
  );
}

📚 Components

SQLiteViewer

Interactive ER diagram component for visualizing database schema.

import { SQLiteViewer } from 'sqlite-visualizer';

<SQLiteViewer
  width={800}
  height={600}
  onTableSelect={(tableName) => console.log('Selected:', tableName)}
/>

Props:

  • width?: number - Diagram width (default: 800)
  • height?: number - Diagram height (default: 600)
  • onTableSelect?: (tableName: string) => void - Callback when table is selected

QueryBuilder

SQL query editor with autocomplete and execution.

import { QueryBuilder } from 'sqlite-visualizer';

<QueryBuilder
  initialQuery="SELECT * FROM users;"
  onQueryChange={(query) => console.log('Query:', query)}
  onExecute={(query, result) => console.log('Result:', result)}
/>

Props:

  • initialQuery?: string - Initial SQL query
  • onQueryChange?: (query: string) => void - Callback on query change
  • onExecute?: (query: string, result: QueryResult) => void - Callback on execution

Hotkeys:

  • Ctrl+Enter - Execute query
  • Ctrl+Space - Show autocomplete
  • Ctrl+Shift+F - Format query

DataExplorer

Table data viewer with filtering, sorting, and pagination.

import { DataExplorer } from 'sqlite-visualizer';

<DataExplorer
  tableName="users"
  onTableChange={(tableName) => console.log('Table:', tableName)}
/>

Props:

  • tableName?: string - Initial table to display
  • onTableChange?: (tableName: string) => void - Callback on table change

QueryPlan

Visual query plan analyzer.

import { QueryPlan } from 'sqlite-visualizer';

<QueryPlan
  initialQuery="SELECT * FROM users WHERE id = 1;"
  viewMode="tree" // or "table"
/>

Props:

  • initialQuery?: string - SQL query to analyze
  • viewMode?: 'tree' | 'table' - Visualization mode

DatabaseManager

Component for loading, creating, and exporting databases.

import { DatabaseManager } from 'sqlite-visualizer';

<DatabaseManager
  onDatabaseLoaded={() => console.log('Database loaded!')}
  onDatabaseCreated={() => console.log('Database created!')}
/>

QueryHistory

View and manage query execution history.

import { QueryHistory } from 'sqlite-visualizer';

<QueryHistory
  onQuerySelect={(query) => console.log('Selected query:', query)}
  maxHeight={400}
/>

🔌 API Reference

useSQLite Hook

Access the SQLite context in your components.

import { useSQLite } from 'sqlite-visualizer';

function MyComponent() {
  const {
    db,                    // Database instance
    isLoading,             // Loading state
    error,                 // Error message
    loadDatabase,          // Load from binary data
    createDatabase,        // Create new database
    executeQuery,          // Execute SQL query
    getSchema,             // Get database schema
    getTableInfo,          // Get table information
    exportDatabase,        // Export database
    saveDatabase,          // Save as .db file
    closeDatabase,         // Close database
    queryHistory,          // Query history array
    addToHistory,          // Add to history
    clearHistory,          // Clear history
  } = useSQLite();

  // Use the methods...
}

Core Utilities

import {
  DatabaseManager as DatabaseManagerCore,
  QueryHistoryManager,
  SQLAutocomplete,
  HotkeyManager,
  QueryShareManager,
} from 'sqlite-visualizer';

// Use core utilities for advanced scenarios

💡 Examples

Loading a Database File

import { useSQLite } from 'sqlite-visualizer';

function LoadDatabase() {
  const { loadDatabase } = useSQLite();

  const handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
    const file = e.target.files?.[0];
    if (file) {
      const arrayBuffer = await file.arrayBuffer();
      await loadDatabase(arrayBuffer);
    }
  };

  return <input type="file" accept=".db,.sqlite" onChange={handleFileChange} />;
}

Creating a Database Programmatically

import { useSQLite } from 'sqlite-visualizer';

function CreateDatabase() {
  const { createDatabase, executeQuery } = useSQLite();

  const setupDatabase = async () => {
    createDatabase();
    
    await executeQuery(`
      CREATE TABLE users (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        name TEXT NOT NULL,
        email TEXT UNIQUE
      );
    `);

    await executeQuery(`
      INSERT INTO users (name, email) VALUES
      ('John Doe', '[email protected]'),
      ('Jane Smith', '[email protected]');
    `);
  };

  return <button onClick={setupDatabase}>Create Database</button>;
}

Exporting Data

import { useSQLite } from 'sqlite-visualizer';

function ExportData() {
  const { exportDatabase, db } = useSQLite();

  const handleExport = () => {
    if (!db) return;

    const sql = exportDatabase({ format: 'sql', schema: true, data: true });
    const blob = new Blob([sql], { type: 'text/plain' });
    const url = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = 'database.sql';
    a.click();
  };

  return <button onClick={handleExport}>Export SQL</button>;
}

🛠️ Development

Prerequisites

  • Node.js 18+
  • npm/yarn/pnpm

Setup

# Clone the repository
git clone https://github.com/Utkautka1/SQLite-Visualizer-Library.git
cd SQLite-Visualizer-Library

# Install dependencies
npm install

# Build the library
npm run build

# Run tests
npm test

# Run demo
cd demo
npm install
npm run dev

Project Structure

sqlite-visualizer/
├── src/
│   ├── components/      # React components
│   ├── core/           # Business logic
│   ├── context/        # React context
│   ├── styles/         # Theme and styles
│   ├── types/          # TypeScript types
│   └── index.ts        # Main export
├── demo/               # Next.js demo app
├── dist/               # Build output
└── package.json

🧪 Testing

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm test -- --coverage

📝 License

MIT License - see LICENSE file for details.


🤝 Contributing

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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

🙏 Acknowledgments


📞 Support


Made with ❤️ for developers

⭐ Star on GitHub📦 npm🐛 Report Bug