How the calculator works
Paste an item as plain JSON or DynamoDB JSON and the calculator shows:
- the size of every attribute - its name and its value - and of the whole item;
- the read and write capacity units (RCU and WCU) one read or write of the item consumes, for each kind of operation;
- how many of those operations per second a table with the given provisioned RCU and WCU handles before requests get throttled.
It follows the rules AWS publishes for item sizes; where AWS gives none (the sets), it uses measured values. Everything runs in your browser. To convert an item between the two formats, use the DynamoDB JSON converter.
How item size is calculated in DynamoDB
An item's size is the sum of its attributes, and every attribute counts twice: the UTF-8 bytes of its name plus the size of its value. Type descriptors such as "S" do not count. Short attribute names save space in every item of the table.
| Type | Size of the value |
|---|---|
String S | UTF-8 bytes of the string |
Number N | 1 byte per two significant digits, plus 1 byte (about; leading and trailing zeros are trimmed) |
Binary B | raw bytes, not the length of the base64 text |
Boolean BOOL, Null NULL | 1 byte |
List L, Map M | 3 bytes, plus each element's size and 1 byte per element (a map element's size includes its name) |
Sets SS, NS, BSNot documented by AWS; measured. | the sum of the elements' sizes, with no overhead |
String
Count UTF-8 bytes, not characters - they differ for anything outside ASCII:
{"id": {"S": "uniqueIdString"}}
id (2) + uniqueIdString (14) = 16 bytes
{"caféName": {"S": "Mocca"}}
caféName (9, "é" takes 2 bytes) + Mocca (5) = 14 bytes, not 13In Node.js, Buffer.byteLength(text, 'utf8') gives the byte count.
Number
Count the significant digits - without leading and trailing zeros, the sign and the decimal point (002321 has four, 0.00200 has one) - take 1 byte per two of them rounded up, and add 1 byte. A negative number takes 1 more byte - measured, AWS does not document it.
{"id": {"N": "777"}}
id (2) + 777 (2) + (1) = 5 bytes
{"id": {"N": "7777"}}
id (2) + 7777 (2) + (1) = 5 bytesBoolean and Null
{"isActive": {"BOOL": true}}
isActive (8) + (1) = 9 bytes
{"phoneNumber": {"NULL": true}}
phoneNumber (11) + (1) = 12 bytesBinary
DynamoDB JSON carries binary data as base64, but the size counts the decoded bytes:
{"picture": {"B": "U29tZSBiaW5hcnkgZGF0YQ=="}}
picture (7) + "Some binary data" (16) = 23 bytesList and Map
{"interests": {"L": [{"S": "Reading"}, {"S": "Traveling"}, {"N": "77"}]}}
interests (9) + (3) + Reading (7) + (1) + Traveling (9) + (1) + 77 (2) + (1) = 33 bytes
{"address": {"M": {
"street": {"S": "Wall Street"},
"city": {"S": "New York"},
"state": {"S": "NY"},
"zipCode": {"S": "12345"}
}}}
address (7) + (3)
+ street (6) + Wall Street (11) + (1)
+ city (4) + New York (8) + (1)
+ state (5) + NY (2) + (1)
+ zipCode (7) + 12345 (5) + (1) = 62 bytesA map costs more than a list with the same values, because every element carries its name.
Sets
Measured: a set is the sum of its elements, each sized like a single value of its type, with no overhead.
{"interests": {"SS": ["Reading", "Traveling", "Cooking"]}}
interests (9) + Reading (7) + Traveling (9) + Cooking (7) = 32 bytes
{"favoriteNumbers": {"NS": ["7", "14", "21"]}}
favoriteNumbers (15) + 7 (2) + 14 (2) + 21 (2) = 21 bytes
{"preferences": {"BS": ["U29tZSBiaW5hcnkgZGF0YTE=", "U29tZSBiaW5hcnkgZGF0YTI="]}}
preferences (11) + "Some binary data1" (17) + "Some binary data2" (17) = 45 bytesFrom item size to read and write capacity
Reads are rounded up to the next 4 KB and writes to the next 1 KB, so a 500-byte item costs as much as a 1 KB one. A 5 KB item takes:
| Operation | Cost | 5 KB item |
|---|---|---|
| Eventually consistent read | 0.5 RCU per 4 KB | 1 RCU |
| Strongly consistent read | 1 RCU per 4 KB | 2 RCU |
| Transactional read | 2 RCU per 4 KB | 4 RCU |
| Standard write | 1 WCU per 1 KB | 5 WCU |
| Transactional write | 2 WCU per 1 KB | 10 WCU |
Query rounds the total size of all the items it returns, so many small items are cheap to read together. BatchGetItem rounds every item on its own, like separate GetItem calls.
Frequently asked questions
Is it safe to paste production data?
Yes. The size is calculated in your browser: the item you paste is not uploaded, not processed on a server, not stored and not logged. The page only counts that the calculator was used, never what you pasted.
What is the maximum size of a DynamoDB item?
400 KB, attribute names and values together. Larger data belongs in Amazon S3, with its key in the item.
Do attribute names count towards the item size?
Yes, in every item. A 20-byte name in 10 million items takes about 200 MB of storage and counts towards the capacity of every read and write.
Why is my item bigger than its JSON?
Lists, maps and numbers add overhead bytes, and a string outside ASCII takes more bytes than it has characters. It can also be smaller: JSON quotes, brackets and type descriptors do not count.
References
DynamoDB item sizes and formats
DynamoDB read and write operations