Question: Can you store objects as DynamoDB items?

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Answer
Yes. A plain object can become a DynamoDB item, and its nested objects can be stored as Map attributes. With the JavaScript v3 document client, you pass normal JavaScript values rather than manually building DynamoDB type descriptors.
import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb"; const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({})); await ddb.send(new PutCommand({ TableName: "Users", Item: { pk: "USER#123", profile: { city: "Seattle", active: true } }, }));
The table in this example needs a String partition key named pk. If your table also has a sort key, include it. The top-level object's properties become attributes; profile becomes a Map.
Use plain data objects rather than assuming arbitrary class instances, dates or functions can be persisted automatically. Convert dates to a deliberate string or numeric representation. Decide how your application handles undefined; it is different from an explicit null.
The whole item, including keys and nested objects, must fit within 400 KB. Serializing a larger object into a string does not bypass the limit. See Node.js examples and nested objects.
Source: AWS JavaScript guide.
Other Common DynamoDB FAQ (with Answers)
- Can Tableau connect to DynamoDB?
- Is a DynamoDB table Region-specific?
- Can you force-delete a DynamoDB table?
- How do you store a graph in DynamoDB?
- Is DynamoDB a relational database?
- Can DynamoDB store documents?
- How is data stored in DynamoDB?
- Is DynamoDB HIPAA compliant?
- Can DynamoDB have duplicates?
- Can Django use DynamoDB?
- How to access DynamoDB from EC2?
- Can DynamoDB have null values?
- Can a DynamoDB range key be a GSI key?
- How do you enable CloudTrail for DynamoDB?
- Are DynamoDB table names unique?
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today