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

@nometria-ai/supabase-export

v1.0.1

Published

Export all your Supabase data to JSON or SQL, and import into any Postgres database. The definitive escape hatch.

Readme

supabase-export

npm version npm downloads Node.js License: MIT

Export all your Supabase data to JSON or SQL — and import into any Postgres. The definitive escape hatch.

"How do I export all my Supabase data?" is one of the most searched Supabase questions. This is the definitive answer: paginated export of every table, with a direct importer into any Postgres target — self-hosted Supabase, Neon, Railway, RDS, or local.


Quick start

# Install
npm install -g @nometria-ai/supabase-export

# Export all tables from your Supabase project
supabase-export export \
  --url https://your-project.supabase.co \
  --key eyJ...service-role-key...

# Import into any Postgres database
supabase-export import \
  --dir ./supabase-export \
  --target postgresql://user:pass@host:5432/db

# List all tables
supabase-export list --url https://your-project.supabase.co --key eyJ...

# Run tests
npm test

Required environment variables (alternative to flags):

SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_KEY=eyJ...             # service role key (not anon key)
TARGET_DATABASE_URL=postgresql://...    # for imports

Install

# Run without installing
npx @nometria-ai/supabase-export export --url https://your-project.supabase.co --key eyJ...

# Install globally
npm install -g @nometria-ai/supabase-export

# Or as a dev dependency
npm install --save-dev @nometria-ai/supabase-export

Export from Supabase

# Export all tables to ./supabase-export/ as JSON
supabase-export export \
  --url https://your-project.supabase.co \
  --key eyJ...service-role-key...

# Export specific tables only
supabase-export export --url ... --key ... --tables users,posts,comments

# Export as SQL INSERT statements (ready to run on any Postgres)
supabase-export export --url ... --key ... --format sql

# Bundle all tables into a single file
supabase-export export --url ... --key ... --bundle

# Use environment variables instead of flags
export SUPABASE_URL=https://your-project.supabase.co
export SUPABASE_SERVICE_KEY=eyJ...
supabase-export export

Output structure:

supabase-export/
├── _manifest.json    ← table list, row counts, export timestamp
├── users.json
├── posts.json
├── comments.json
└── ...

Import to any Postgres

# Import into any Postgres (Neon, Railway, RDS, self-hosted Supabase, local)
supabase-export import \
  --dir ./supabase-export \
  --target postgresql://user:pass@host:5432/db

# Dry run first — validates data without writing anything
supabase-export import --dir ... --target ... --dry-run

# Import only specific tables
supabase-export import --dir ... --target ... --tables users,posts

# Use environment variable
export TARGET_DATABASE_URL=postgresql://...
supabase-export import --dir ./supabase-export

List tables

supabase-export list --url https://your-project.supabase.co --key eyJ...

CLI reference

supabase-export <command> [options]

Commands:
  export    Export data from Supabase to local files
  import    Import exported data into any Postgres database
  list      List all tables in a Supabase project

Export options:
  --url      Supabase project URL  [env: SUPABASE_URL]
  --key      Service role key      [env: SUPABASE_SERVICE_KEY]
  --tables   Comma-separated table names (default: all)
  --schema   Schema to export (default: public)
  --format   json | sql (default: json)
  --dir      Output directory (default: ./supabase-export)
  --bundle   Write all tables into one export.json

Import options:
  --dir      Export directory to read from (default: ./supabase-export)
  --target   Target Postgres connection URL  [env: TARGET_DATABASE_URL]
  --tables   Comma-separated table names (default: all from manifest)
  --dry-run  Validate without writing

Use as a library

import { exportSupabase } from '@nometria-ai/supabase-export/exporter';
import { importToPostgres } from '@nometria-ai/supabase-export/importer';

const result = await exportSupabase({
  supabaseUrl:  process.env.SUPABASE_URL,
  supabaseKey:  process.env.SUPABASE_SERVICE_KEY,
  tables:    ['users', 'posts'],
  format:    'json',
  outDir:    './backup',
});

await importToPostgres({
  exportDir:  './backup',
  targetUrl:  process.env.TARGET_DATABASE_URL,
});

Important: use the service role key

The anon key cannot bypass Row Level Security and won't be able to read all rows. You need the service role key:

Supabase Dashboard → Project Settings → API → Service role key (secret)

Never expose the service role key in client-side code or commit it to your repository. Use environment variables.


Common use cases

Migrate to a self-hosted Supabase instance

# 1. Export from Supabase Cloud
supabase-export export --url https://xyz.supabase.co --key eyJ...

# 2. Import to self-hosted (or Neon, Railway, etc.)
supabase-export import --dir ./supabase-export \
  --target postgresql://postgres:password@localhost:5432/postgres

Scheduled backups (GitHub Actions)

# .github/workflows/backup.yml
on:
  schedule:
    - cron: '0 2 * * *'   # daily at 2am
jobs:
  backup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npx @nometria-ai/supabase-export export --dir ./backup
        env:
          SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
          SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }}

Technical details

  • Pagination: fetches 1,000 rows per request using Supabase's .range() — handles tables with millions of rows
  • SQL output: produces INSERT INTO "schema"."table" (...) VALUES (...) ON CONFLICT DO NOTHING;
  • Import batching: inserts 500 rows per batch; falls back to row-by-row on conflict
  • Manifest: _manifest.json written on every export for import validation

Contributing

PRs welcome. Run tests with npm test.


License

MIT © Nometria


Example output

Running node --test tests/exporter.test.js:

✔ toSqlValue handles null (0.37875ms)
✔ toSqlValue handles numbers (0.066541ms)
✔ toSqlValue handles booleans (0.056208ms)
✔ toSqlValue escapes single quotes in strings (0.057792ms)
✔ toSqlValue serialises objects as JSON (0.75875ms)
✔ toSqlInsert produces valid INSERT statement (0.591917ms)
ℹ tests 6
ℹ suites 0
ℹ pass 6
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 84.789375

CLI help output:

supabase-export — Export and import Supabase data

Commands:
  export    Pull data from Supabase to local JSON/SQL files
  import    Load exported data into any Postgres database
  list      List all tables in a Supabase project
...

See examples/sample-export/ for what an export directory looks like, including _manifest.json and users.json.