How to convert a boto3 Dynamo DB item to a regular dictionary in Python?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When you use the low-level boto3 DynamoDB client, returned items are wrapped in DynamoDB AttributeValue objects rather than ordinary Python values. The clean solution is to deserialize them as soon as they cross the repository boundary so the rest of the application can work with normal dictionaries.
Know Which boto3 API You Are Using
This problem applies mainly to the low-level client API.
- '
boto3.client("dynamodb")returns AttributeValue maps' - '
boto3.resource("dynamodb")usually gives you normal Python-style values'
A low-level item looks like this:
That format is correct for the wire protocol, but it is awkward in normal business logic.
Use TypeDeserializer
boto3 already includes the right conversion tool: TypeDeserializer.
This correctly handles nested maps and lists, so there is little reason to hand-roll your own recursive parser.
Decode Query and Scan Results the Same Way
Most real code works with multiple items from query or scan, not just one record. Wrap the same logic in a helper for result sets.
That keeps all DynamoDB deserialization behavior consistent across your data-access layer.
Understand Decimal Values
DynamoDB numbers deserialize to Decimal, not plain int or float. That preserves precision, but it can surprise code that expects JSON-serializable primitives.
If the values represent money or other precision-sensitive quantities, converting to float may be the wrong choice. In those cases, strings or domain-specific serializers are often safer.
Deserialize at the Repository Boundary
A good pattern is to convert the item immediately after reading it from DynamoDB and keep the rest of the application isolated from AttributeValue syntax.
That keeps services, handlers, and tests free from low-level DynamoDB wire-format details.
Common Pitfalls
The biggest mistake is mixing the low-level client and higher-level resource API without noticing which one already performs deserialization.
Another common issue is reimplementing recursive conversion logic by hand when boto3 already provides the correct tool. Developers also often convert every Decimal to float automatically and then discover precision loss later in analytics or billing code.
Summary
- Low-level boto3 client items need explicit deserialization.
- '
TypeDeserializeris the built-in tool for converting DynamoDB AttributeValue maps.' - Use a shared helper for query and scan result sets.
- Treat
Decimalconversion as a domain decision, not an afterthought. - Deserialize at the repository boundary so the rest of the app can use normal dictionaries.

