Error: dynamodb unable to parse base64 string

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
“Unable to parse base64 string” means a value expected to represent binary data has an invalid encoding. Raw DynamoDB JSON represents Binary attributes as base64 strings. SDK APIs generally accept native bytes and perform the wire encoding for you.
import base64
import boto3
encoded = "aGVsbG8="
payload = base64.b64decode(encoded, validate=True)
db = boto3.client("dynamodb", region_name="us-east-1")
db.put_item(TableName="Files", Item={
"id": {"S": "file-123"},
"payload": {"B": payload},
})Decode a data URL’s payload only after separating its prefix, and distinguish base64 from URL-safe base64. Reject malformed input instead of adding arbitrary padding. In JavaScript SDK v3, use a Buffer or Uint8Array for Binary. If the value is ordinary text, store it as a String attribute rather than marking it Binary.
Check whether an import tool expects DynamoDB JSON or plain application JSON. Encoding an already encoded string again produces the wrong stored bytes even if validation succeeds. IAM changes do not repair malformed base64.
Other Common DynamoDB Errors (with Solutions)
- dynamodb cannot read property '0' of undefined
- DynamoDB - The Security Token Included In The Request Is Invalid
- DynamoDB scan filter expression not working
- Could not connect to the endpoint URL https:dynamodb.singapore.amazonaws.com
- aws.dynamodb.documentclient is not a constructor
- DynamoDB attribute not empty
- dynamodb system errors metric
- ProvisionedThroughputExceededException DynamoDB
- dynamodb put item not working
- ImportError: No module named boto3 (DynamoDB)
- dynamodb unknown error
- dynamodb atomic counter not working
- ValidationException: Invalid KeyConditionExpression: Attribute name is a reserved keyword;
- DynamoDB parameter validation failed
- dynamodb update fail if not exists
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
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