dynobase-icon
Dynobase

DynamoDB: Delete Multiple Items in Javascript (Guide w/ Code Examples)

Rafal Wilinski

Provided by Rafal Wilinski

Last updated: October 23rd, 2026

BatchWriteCommand can delete a set of known full primary keys. Each delete is atomic, but the batch is not; retry UnprocessedItems and retain failed work when retries are exhausted.

Install @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb, use an ES module on a supported Node.js runtime, and configure an AWS Region and credentials. The examples use an existing Orders table with String keys pk and sk unless an index or timestamp key is described.

import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; import { DynamoDBDocumentClient, BatchWriteCommand } from "@aws-sdk/lib-dynamodb"; const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({})); const writes = ["ORDER#001", "ORDER#002"].map(sk => ({ DeleteRequest: { Key: { pk: "CUSTOMER#123", sk } }, })); let pending = { Orders: writes }; for (let attempt = 0; Object.keys(pending).length > 0; attempt++) { if (attempt === 8) throw new Error("Batch write incomplete: persist pending writes for retry"); if (attempt > 0) await new Promise(resolve => setTimeout(resolve, Math.random() * Math.min(5000, 100 * 2 ** attempt))); const result = await ddb.send(new BatchWriteCommand({ RequestItems: pending })); pending = result.UnprocessedItems ?? {}; }

Limit each batch to 25 operations. Use conditional DeleteCommand requests instead when an item must still match an expected version or state.

Reference: AWS BatchWriteItem API. For related access patterns, see DynamoDB query examples.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Changelog
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.