Question: How do you store JSON on DynamoDB?

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Answer
Store JSON as native DynamoDB attributes using a document client: objects become Maps, arrays become Lists, and primitive values keep their supported types. You do not need to stringify the document.
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: "Orders", Item: { pk: "ORDER#42", shipping: { city: "Seattle" }, items: [{ sku: "BOOK#1", quantity: 2 }], paid: false, }, }));
This assumes a String partition key named pk. Add the sort key if the table requires one. PutCommand replaces an existing item with the same key; use a condition for create-only behavior or UpdateCommand for partial changes.
Plain JSON differs from DynamoDB JSON, where values have descriptors such as S, N and M. Document clients perform that conversion. Java users can use the SDK 2.x Enhanced Client or Enhanced Document API rather than the retired SDK 1.x mapper.
Keep the complete item within 400 KB. Larger documents belong in S3, with their location and searchable fields stored in DynamoDB. See the JSON converter and Node.js examples.
Source: AWS JavaScript document client.
Other Common DynamoDB FAQ (with Answers)
- What does DynamoDB Query return?
- Is DynamoDB serverless?
- How to access DynamoDB from EC2?
- How do you handle empty strings in DynamoDB?
- Does DynamoDB support load balancing?
- Can DynamoDB store images?
- Why is DynamoDB better than MongoDB?
- Can QuickSight read DynamoDB?
- Can DynamoDB have nested objects?
- Is connection pooling needed for DynamoDB?
- What are the naming conventions in DynamoDB?
- What is an access pattern in DynamoDB?
- Is DynamoDB ACID compliant?
- Can you store lists in DynamoDB?
- Can DynamoDB trigger AWS Step Functions?
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today