A command-line tool for migrating MongoDB databases to SQLite/LibSQL with automatic schema inference and type mapping.
Download the latest release for your platform from the Releases page.
Extract the binary and optionally add it to your PATH:
# macOS/Linux
tar -xzf mongo-to-sqlite-*.tar.gz
sudo mv mongo-to-sqlite /usr/local/bin/
# Or place it in your preferred location
mv mongo-to-sqlite ~/.local/bin/The tool uses environment variables for configuration. Create a .env file in your project directory:
cp env.example .envEdit the .env file with your configuration:
# MongoDB Connection
MONGODB_URI=mongodb://localhost:27017
# Turso Cloud (optional - omit to use local SQLite file)
TURSO_DATABASE_URL=libsql://your-database.turso.io
TURSO_AUTH_TOKEN=your-auth-token
# Logging Level (optional)
RUST_LOG=infoThe tool automatically loads these variables at runtime.
Migrate all collections to a local SQLite file:
mongo-to-sqlite --database mydb --all-tables --output mydb.dbMigrate a specific collection:
mongo-to-sqlite --database mydb --table users --output users.dbPreview schema without migrating data:
mongo-to-sqlite --database mydb --all-tables --schema-only --output schema.dbMigrate to Turso cloud (requires TURSO_DATABASE_URL and TURSO_AUTH_TOKEN in .env):
mongo-to-sqlite --database mydb --all-tablesOptions:
-d, --database <DATABASE> MongoDB database name (required)
--mongodb-uri <URI> MongoDB connection string [default: mongodb://localhost:27017]
-t, --table <TABLE> Migrate specific table/collection
--all-tables Migrate all tables/collections
--schema-only Migrate schema only (no data)
--data-only Migrate data only (assumes schema exists)
-o, --output <OUTPUT> Output SQLite file path [default: output.db]
--batch-size <SIZE> Batch size for inserts [default: 1000]
--sample-size <SIZE> Number of documents to sample for schema [default: 100]
-h, --help Print help
-V, --version Print version
| MongoDB Type | SQLite Type | Notes |
|---|---|---|
| String | TEXT | Direct mapping |
| Int32/Int64 | INTEGER | Direct mapping |
| Double | REAL | Direct mapping |
| Boolean | INTEGER | 0 = false, 1 = true |
| Date | TEXT | ISO 8601 format |
| ObjectId | TEXT | Hex string |
| Array | TEXT | JSON serialized |
| Object | TEXT | JSON serialized |
| Binary | BLOB | Direct mapping |
- Quick Start - Get started in 5 minutes
- Type Mappings - Complete type mapping details
This project is licensed under the MIT License - see the LICENSE file for details.