mongodb
sqlite

Migrate MongoDB to SQLite

Beta — live-tested path

The converter maps 15 MongoDB column types to SQLite. 9 of them change kind on the way (ObjectId becomes TEXT, Decimal128 becomes TEXT, Boolean becomes INTEGER, and more); the table below lists every one. Documents become rows: the schema is inferred by sampling the collection, and nested data lands in JSON columns. DBShifts creates the inferred tables, copies the documents in parallel batches and checks the result with row counts.

Start MongoDB → SQLite Migration

Free tier · no credit card

MongoDB vs SQLite

mongodb

MongoDB

the leading document database.

sqlite

SQLite

the embedded database that ships inside everything.

MongoDB to SQLite data type mapping

Pulled directly from DBShifts's own conversion rules — not a general reference table, this is what actually runs.

MongoDBSQLite
ObjectIdTEXT
String (up to 255 chars)TEXT
String (longer)TEXT
Int32INTEGER
Int64INTEGER
DoubleREAL
Decimal128TEXT
BooleanINTEGER
DateTEXT
TimestampTEXT
BinaryBLOB
ArrayTEXT
Object / subdocumentTEXT
UUIDTEXT
NullTEXT

Example: MongoDB to SQLite conversion

MongoDB

// one document from the "orders" collection
{
  "_id":         ObjectId("6512c3a1f4b2e9d0a7c1b234"),
  "customer_id": NumberLong(4821),
  "total":       NumberDecimal("129.99"),
  "is_gift":     false,
  "notes":       "leave at reception",
  "tags":        ["priority", "fragile"],
  "placed_at":   ISODate("2026-03-14T09:20:00Z")
}

SQLite

CREATE TABLE IF NOT EXISTS "orders" (
    "_id" TEXT,
    "customer_id" INTEGER NOT NULL,
    "total" TEXT NOT NULL,
    "is_gift" INTEGER,
    "notes" TEXT,
    "tags" TEXT,
    "placed_at" TEXT NOT NULL,
    PRIMARY KEY ("_id")
);

Two schemaless-adjacent databases with opposite habits

MongoDB has no schema and SQLite has one it does not enforce, which sounds like a comfortable match and is not. The target still needs columns declared, so the document structure must be flattened into a fixed set of them, and the fact that SQLite will not enforce those declarations does not remove the need to choose them.

The schema is inferred by sampling documents, so a field that appears in few documents may be missed and a field with mixed types is widened to text. Reviewing the inferred columns before loading is the step that makes this predictable.

What this is usually for

The common reasons are analysis and portability: getting a collection into a single file that opens in any SQLite tool, or producing a fixture for tests that must not depend on a running MongoDB. Both favour a subset over a full copy.

Because the output is one file, it is also the format people share. That makes masking worth applying at extract time rather than afterwards, since a copied file cannot be unshared.

Arrays, nested documents and JSON1

Arrays and nested objects become JSON text. SQLite's JSON1 functions can query into that text, so the data is not opaque, but it is not indexed as columns and querying it is slower than a real column would be.

Where an array is the interesting part of the data, extracting it into a child table with a foreign key back to the parent gives a far more useful result than a JSON blob. That is a modelling choice worth making explicitly rather than accepting the default.

MongoDB → SQLite conversion notes

Engine-specific rules baked into the conversion and transfer pipeline — verified by live certification of this exact pair.

  • Schema is inferred by sampling documents — null values don't poison type inference (a nullable int stays an int column).
  • Decimal128 maps to exact DECIMAL on SQL targets, never a float round-trip.
  • Nested documents and arrays land as JSON/JSONB columns with data preserved byte-for-byte.
  • _id becomes the primary key; ObjectId converts to its 24-character hex form.
  • High-precision decimals land in TEXT columns on purpose — SQLite's NUMERIC affinity would silently convert them to lossy REAL.
  • Unsigned BIGINT values beyond the signed 64-bit range are stored as exact text rather than corrupted floats.
  • Dates and times are stored as ISO-8601 text, the SQLite convention.

Frequently asked questions

Is MongoDB to SQLite migration production-ready in DBShifts?

MongoDB to SQLite is in beta. It runs on real servers in the certification suite, which checks it by row counts; the content checks that certify the SQL pairs do not yet compare documents with rows. Every migration still ends with a fidelity report to audit before cutover.

What happens to MongoDB types that SQLite doesn't have?

Each gets the nearest SQLite type the converter treats as safe: ObjectId becomes TEXT, Decimal128 becomes TEXT, Boolean becomes INTEGER, Date becomes TEXT, Timestamp becomes TEXT. Every such decision is in the migration plan before anything runs, and any mapping can be overridden per column.

Can I keep MongoDB and SQLite in sync after the initial migration?

Yes, until you cut over. DBShifts follows a change stream from a resume token taken before the first document is copied. Change streams need a replica set or a sharded cluster; a standalone server cannot stream.

Which MongoDB data types need a second look when moving to SQLite?

The table above carries a note on 5 of them: ObjectId (TEXT), Decimal128 (TEXT), Array (TEXT), Object / subdocument (TEXT) and more. Analysis flags the same columns on your own schema before any data moves.

Go deeper

Ready to move MongoDB to SQLite?

Set up in under two minutes. Validation and rollback included.

Start Free Migration