Loading MongoDB to DynamoDB Converter...
Please wait a moment

MongoDB to DynamoDB Converter Online — Migrate NoSQL Queries Between Databases

Paste your MongoDB query above and get the equivalent AWS DynamoDB operation as request params for the AWS SDK. It reads find(), aggregate(), insertOne(), updateOne(), deleteOne() and more, and everything runs in your browser.

How to Convert MongoDB to DynamoDB — Step-by-Step

Step 1

Input Your MongoDB Query

Migrating from MongoDB to AWS DynamoDB? Paste your MongoDB query directly — the converter handles both MongoDB shell syntax (unquoted keys) and strict JSON format.

•
Paste directly: Copy your MongoDB query from MongoDB Compass, your shell, or application code
•
Upload a file: Click "Upload" to select a .js or .json file
•
Load a sample: Click "Sample" to see a MongoDB find() with filters converted to DynamoDB

Example: MongoDB find() Query

A typical MongoDB query with comparison and regex operators:

db.users.find(
  {
    "status": "active",
    "age": { "$gte": 21 },
    "country": { "$in": ["US", "UK"] }
  }
)
Step 2

Automatic Conversion to DynamoDB

The converter maps MongoDB query operators to their DynamoDB equivalents:

•
Operators: MongoDB $gt, $gte, $lt, $ne, $in become DynamoDB comparison expressions
•
Typed values: Strings become {"S": "value"}, numbers become {"N": "42"}, matching the DynamoDB data type format
•
What you get: the import line, the params object and the AWS SDK v3 send() call, plus NOTE lines for anything DynamoDB handles differently

Example: DynamoDB Scan Output

The MongoDB query above converted to a DynamoDB Scan:

const params = {
  "TableName": "users",
  "FilterExpression": "#status = :val0 AND #age >= :val1 AND #country IN (:val2, :val3)",
  "ExpressionAttributeNames": { ... },
  "ExpressionAttributeValues": { ... }
};
Step 3

Copy or Download Your DynamoDB Code

When it looks right, grab it:

•
Copy to clipboard: One click — paste into your Lambda function, Node.js app, or AWS CLI script
•
Download as file: Save as a .js file for your project
•
Try other converters: Convert to SQL instead, or go the other way with SQL to DynamoDB. Format your MongoDB queries with the MongoDB Query Formatter

Frequently Asked Questions — MongoDB to DynamoDB

What can I paste into the converter?

A mongosh call such as db.users.find({ status: "active" }), db.getCollection("users").updateOne(…) or several calls on separate lines. Shell syntax works the way you would type it in mongosh: unquoted keys, single quotes, comments, ObjectId(), ISODate(), new Date("…"), NumberLong(), NumberDecimal(), BinData() and /regex/ literals, and Extended JSON such as {"$oid": "…"} or {"$numberLong": "…"} too. A bare filter object becomes a Scan on a placeholder table, and a bare list of documents becomes a BatchWriteItem. If something can't be read, the error names the line and column.

Which query operators are converted?

Plain matches, $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $exists, $type, $size and $all, combined with $and, $or, $nor and $not, become a FilterExpression. Dotted paths such as address.city become nested attribute paths. A field: null match also finds items where the attribute is missing, as in MongoDB. Regular expressions are only converted when they are plain text: /^jo/ becomes begins_with(), /jo/ becomes contains() and /^jo$/ an exact match. Anything DynamoDB has no form for, like case-insensitive regexes or $elemMatch, is left out and named in a NOTE line at the top of the output, so the scan returns extra items rather than missing some.

How are updates and deletes converted?

UpdateItem and DeleteItem work on one item, so the filter has to hold the item's key. If it has an _id, that becomes the Key; otherwise every plain field becomes the Key and a note asks you to keep only your partition and sort key. Other filter conditions move into ConditionExpression. $set, $unset, $inc, $push, $addToSet, $rename and $setOnInsert become an UpdateExpression. Because DynamoDB creates the item when the key is new, an update without { upsert: true } gets a ConditionExpression that makes it fail when the item does not exist. updateMany() and deleteMany() still turn into a single-item call with a note, and deleteMany({}) is refused instead of producing a request that could not work.

Will long numbers and other types come through exactly?

Yes. Numbers go into N values as the text you typed, so 8901240544102066246 keeps every digit and 14.50 stays 14.50; DynamoDB holds up to 38 significant digits. A quoted "00501" stays a string, while an unquoted 00501 is refused because mongosh would read it as an octal number. ObjectId("…") becomes its 24-character hex string, ISODate() and new Date() an ISO 8601 string, BinData() a B value, true/false BOOL and null NULL. Arrays become lists (L), not sets, because MongoDB arrays keep their order and may repeat values.

Does it handle aggregation pipelines?

$match, $project, $limit and $count at the start of a pipeline turn into a Scan with a FilterExpression, a ProjectionExpression and Select: COUNT. Stages such as $group, $lookup, $unwind and $sort have no DynamoDB equivalent; the output lists them in a note so you know which steps to do in your own code after the scan.

Why doesn't findOne() or .limit() set Limit?

DynamoDB applies Limit before the FilterExpression, so Limit: 1 means "read one item, then filter it", which often returns nothing. When the query has a filter, the converter leaves Limit out and adds a note to take the first items from the result instead. Without a filter, Limit is set as you would expect.

What are the main differences between MongoDB and DynamoDB?

MongoDB is a document database with flexible querying, while DynamoDB is a key-value and wide-column store built around the access patterns you design up front. MongoDB has joins through $lookup, rich aggregation pipelines and ad-hoc queries on any field. DynamoDB reads items by partition and sort key, filters only after reading, and has no sorting outside a key. That is why some MongoDB operations come out as notes rather than code.

Is my query sent anywhere?

No. The conversion runs in your browser, and nothing you paste or upload is sent to a server or kept. Reload the page and the editor starts empty again.

Related converters: SQL to MongoDB · MongoDB to SQL · SQL to DynamoDB · DynamoDB to MongoDB · DynamoDB to SQL · MongoDB Query Formatter