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

turso-introspect

v0.1.0

Published

A CLI tool to introspect the database schema of a Turso/libsql database.

Readme

Turso Introspect CLI

A CLI tool to introspect the database schema of a Turso/libsql database. Point it at a remote Turso database and get a clean, executable schema file.

Installation

# npm
npm install -g turso-introspect

# bun
bun install -g turso-introspect

Quick Start

# Using database URL
turso-introspect libsql://mydb-myorg.turso.io

# Using database name (requires --org)
turso-introspect mydb --org myorg

# Output to specific file
turso-introspect mydb --org myorg -o ./schemas/mydb.sql

# JSON output
turso-introspect mydb --org myorg --format json

# Write to stdout
turso-introspect mydb --org myorg --stdout

Authentication

The CLI supports three authentication methods (in order of precedence):

  1. Command-line flag (highest priority):

    turso-introspect mydb --org myorg --token "your-token"
  2. Environment variable (recommended for CI/CD):

    export TURSO_AUTH_TOKEN="your-token"
    turso-introspect mydb --org myorg
  3. Turso CLI authentication (automatic):

    # If you're logged in via the Turso CLI, no token is needed
    turso auth login
    turso-introspect mydb --org myorg

Token Types

The CLI automatically handles both token types:

  • Platform tokens (from turso auth login or turso auth token): Used to manage Turso resources. When detected, the CLI automatically exchanges it for a database token via the Turso API.
  • Database tokens (from turso db tokens create <db>): Used directly for database connections.

You can use either token type with --token or TURSO_AUTH_TOKEN. The CLI detects which type you've provided and handles it appropriately.

Note: When using platform tokens, the --org flag is required to generate database tokens.

Database Identification

Databases can be specified in two ways:

  1. Full URL: libsql://mydb-myorg.turso.io
  2. Database name: Requires --org flag to specify the organization

Output Formats

SQL (default)

Produces executable SQL with:

  • Tables sorted in topological order based on foreign key dependencies
  • Foreign key constraints as separate ALTER TABLE statements (enables order-independent execution)
  • Indexes, views, and triggers included
  • Virtual tables (FTS5, R-tree, etc.) output as comments only
  • Minimal header comment with generation timestamp

JSON

Structured output with categorized schema objects.

Table Filtering

# Only specific tables
turso-introspect mydb --org myorg --tables users,posts,comments

# Exclude specific tables
turso-introspect mydb --org myorg --exclude-tables logs,sessions

Schema Diff Command

Compare schemas between databases or files:

# Compare two live databases
turso-introspect diff libsql://db1.turso.io libsql://db2.turso.io

# Compare database against local file
turso-introspect diff libsql://production.turso.io ./local-schema.sql

# Output as migration SQL
turso-introspect diff db1 db2 --org myorg --diff-format migration

CLI Reference

turso-introspect [database] [options]

Arguments:
  database              Database URL (libsql://...) or name

Options:
  --org <name>          Organization name (required when using db name)
  --token <token>       Authentication token (overrides TURSO_AUTH_TOKEN)
  -o, --output <path>   Output file path (default: {db}-schema.{sql|json})
  --stdout              Write to stdout instead of file
  --format <type>       Output format: sql (default) or json
  --tables <list>       Comma-separated list of tables to include
  --exclude-tables <l>  Comma-separated list of tables to exclude
  --include-system      Include SQLite/libsql system tables
  --normalize-defaults  Normalize common DEFAULT expressions
  --check               Validate connection without producing output
  -q, --quiet           Suppress warnings and informational output
  -v, --verbose         Show detailed progress information
  -h, --help            Show help
  --version             Show version

Subcommands:
  diff <db1> <db2>      Compare schemas between two sources
    --diff-format <f>   Output format: diff (default) or migration
    --org <name>        Organization (when using db names)
    --token <token>     Authentication token

Development

bun install
bun run src/index.ts --help
bun run build        # Build with tsdown
bun run dev          # Watch mode