DynamoDB: Bulk Insert (Guide w/ Code Examples)

Provided by Rafal Wilinski
There are a few ways to bulk insert data into DynamoDB tables using the AWS JavaScript SDK. One way is to use the batchWrite method of the DynamoDB DocumentClient to write multiple items to a table in a single request.
Here's an example of how to use the batchWrite method to insert items into a DynamoDB table:
const AWS = require('aws-sdk'); const dynamoDb = new AWS.DynamoDB.DocumentClient(); const tableName = 'myTable'; const items = [ { id: '123', name: 'John' }, { id: '456', name: 'Jane' }, { id: '789', name: 'Bob' }, // ... ]; const requests = items.map((item) => { return { PutRequest: { Item: item } } }); const chunks = chunkArray(requests, 25); chunks.forEach((chunk) => { dynamoDb.batchWrite({ RequestItems: { [tableName]: chunk } }).promise() .then(data => { console.log("Items written successfully"); }) .catch(err => { console.error(err); }); }); function chunkArray(myArray, chunk_size){ var results = []; while (myArray.length) { results.push(myArray.splice(0, chunk_size)); } return results; }
Similar Code Examples
- DynamoDB: Delete Multiple Items in Javascript
- DynamoDB: Query JSON
- DynamoDB: Query KeyConditionExpression
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Get Last 10 Records
- DynamoDB: Query Greater Than
- DynamoDB: BatchGetItem
- DynamoDB: Query Group By
- DynamoDB: Query Global Secondary Index in Nodejs
- DynamoDB: Like
- DynamoDB: Increment Counter
- DynamoDB: Delete All Items With Partition Key
- DynamoDB: Not Begins With
- DynamoDB: Get Last Inserted Item
- DynamoDB: Query Items
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
DynamoDB Tools
DynamoDB Info
© 2026 Dynobase