DynamoDB to SQL Converter Online — Convert DynamoDB Operations to SQL Queries
Paste your DynamoDB params JSON above and get the equivalent SQL query next to it. Handles FilterExpression, ExpressionAttributeNames, typed attribute values, reads, writes, updates and deletes, and the whole conversion runs in your browser.
How to Convert DynamoDB to SQL — Step-by-Step
Input Your DynamoDB Params
Got a DynamoDB params object you need to understand as SQL? Three ways to load it:
const params = {...} or new QueryCommand({...}) works too, and so does Scan output with an Items list.json or .js fileExample: DynamoDB Scan Params
Here is a typical DynamoDB Scan params object you might want to understand as SQL:
{ "TableName": "users", "FilterExpression": "#status = :statusVal", "ExpressionAttributeNames": { "#status": "status" }, "ExpressionAttributeValues": { ":statusVal": { "S": "active" } }, "Limit": 25 }
Automatic Conversion to SQL
The converter parses your DynamoDB API params and generates readable SQL:
contains(), begins_with(), and attribute_exists() become familiar SQL LIKE and IS NOT NULL{"S": "active"} become SQL-friendly 'active'Example: SQL Output
The DynamoDB params from Step 1 converted to SQL:
SELECT * FROM users WHERE status = 'active' LIMIT 25;
Copy or Download Your SQL Query
When it looks right, grab it:
.sql fileFrequently Asked Questions — DynamoDB to SQL
Which DynamoDB calls does it understand?
Scan and Query become SELECT, with KeyConditionExpression and FilterExpression joined by AND. GetItem becomes a SELECT on the key, PutItem an INSERT, UpdateItem an UPDATE (SET, REMOVE and numeric ADD) and DeleteItem a DELETE. BatchWriteItem, BatchGetItem and TransactWriteItems are split into their statements, and Scan or Query output with an Items list turns into INSERT rows.
How does it tell GetItem from DeleteItem?
Both take the same params: a TableName and a Key. If your code wraps them, as in new DeleteItemCommand({...}) or docClient.delete({...}), the page follows the command name. With bare JSON it writes a SELECT, because reading a row is the safe guess, and says so in a note above the SQL.
What happens to typed values like S, N and M?
S becomes a quoted string, N is written as a bare number exactly as it appears inside the quotes, BOOL becomes TRUE or FALSE and NULL becomes NULL. Maps, lists and sets (M, L, SS, NS, BS) are written as JSON text, and B is kept as its Base64 text. Plain values from the DocumentClient work too.
Will long IDs or prices change on the way through?
No. DynamoDB sends numbers as text, so an N value of 8901240544102066246 is written as 8901240544102066246, not rounded the way a JavaScript number would be, and 14.50 stays 14.50. A string such as 00501 stays a quoted string, so the leading zeros survive.
Is the SQL safe to run?
Quotes inside values are doubled, so a value like O'Brien or one containing a DROP TABLE trick stays a plain string. Table and column names are put in double quotes when they hold spaces, dots or reserved words. The output follows standard SQL, which suits PostgreSQL, SQLite, SQL Server and Oracle; for MySQL, see the note the page shows when a value contains a backslash. Still read the statement before running it against real data.
What does contains() or begins_with() become?
begins_with(name, 'adm') becomes name LIKE 'adm%' and contains(name, 'x') becomes name LIKE '%x%'. A % or _ in your value is escaped so it is matched literally. attribute_exists() and attribute_not_exists() become IS NOT NULL and IS NULL, and size() becomes LENGTH(). On a list or set, contains() checks for a member in DynamoDB, which LIKE does not do, so the page adds a note.
Does my data leave the browser?
No. The conversion runs in this page, nothing you paste is uploaded, and nothing is kept: reloading the page starts with an empty editor.
More NoSQL converters: MongoDB to SQL, SQL to DynamoDB, MongoDB to DynamoDB and, for ordinary JSON rows, JSON to SQL.
Related Tools
SQL to MongoDB
Convert SQL queries to MongoDB query syntax with aggregation pipeline support
MongoDB to SQL
Convert MongoDB queries and aggregation pipelines to equivalent SQL statements
SQL to DynamoDB
Convert SQL queries to AWS DynamoDB query and scan operations with PartiQL support
MongoDB Query Formatter
Format, beautify, and validate MongoDB queries with proper indentation and syntax highlighting
MongoDB to DynamoDB
Convert MongoDB queries to AWS DynamoDB query operations and vice versa
DynamoDB to MongoDB
Convert AWS DynamoDB operations to MongoDB queries with proper operator mapping