Import JSON into a DynamoDB table
Quick answer
How do I import a JSON file into an existing DynamoDB table?
AWS's managed import from S3 only creates a new table. To add JSON items to a table that already exists, write them yourself:
- A plain JSON array: a short script. boto3's
batch_writer()groups writes into batches of 25 and resends unprocessed items. Parse decimals asDecimal, because boto3 rejects floats:import json, boto3 from decimal import Decimal table = boto3.resource("dynamodb").Table("Orders") with open("orders.json") as f: items = json.load(f, parse_float=Decimal) with table.batch_writer() as batch: for item in items: batch.put_item(Item=item) - DynamoDB JSON: the AWS CLI.
aws dynamodb batch-write-item --request-items file://batch.jsontakes up to 25 items per call in the typed format ({"S": "..."}), and you must resend anything it returns inUnprocessedItems.
Both replace any item with the same primary key. If existing items must be kept, use individual PutItem calls with an attribute_not_exists condition instead. Every write consumes write capacity. To do it without a script, Dynobase previews the file and its types first and lets you overwrite, skip or merge items whose keys already exist; the steps are below.
Dynobase imports a local JSON file into an existing DynamoDB table. Preview the records, check key and attribute types, and choose how to handle existing keys before starting. AWS also provides managed S3 import, which creates a new table rather than adding data to an existing one.
Choose the destination profile, Region, and table, then select Import and Import from file.
Select your JSON file and review the preview, attribute types, and primary keys. Choose the Import Merging Strategy and write concurrency; validate a representative sample before a large import.
Start the import, wait for completion, and inspect failures. Run a fresh query or scan with Cmd+R on macOS or Ctrl+R on Windows/Linux to check the imported items.
Frequently Asked Questions
What other import methods does AWS provide?
Is importing a file free?
What affects import speed?
What happens when an item with the same key exists?
How should I prepare the file?
Product Features
DynamoDB Tools
- SSH GUI Client
- Chat With Cloud
- MongoDB GUI Client
- AWS Cost Monitoring
- DynamoDB Query Builder
- DynamoDB Code Examples
- DynamoDB Node.js Queries
- DynamoDB JSON Converter
- DynamoDB UUID Generator
- DynamoDB Local Admin GUI
- DynamoDB Pricing Calculator
- DynamoDB Single-Table Design
- Best DynamoDB GUI Clients
- Dynobase vs DynoTable