Size of hashkey has exceeded the maximum size limit of 2048 bytes

TL;DR — DynamoDB caps key lengths: a partition (hash) key value can be at most 2048 bytes, and a sort (range) key value at most 1024 bytes, measured as UTF-8 (or raw binary) bytes. A write whose key exceeds the limit is rejected. Shorten the key — hash long values, or move the bulky data into a non-key attribute.

What it means

ValidationException: One or more parameter values were invalid: Size of hashkey has exceeded the maximum size limit of2048 bytes

# sort-key variant:
ValidationException: One or more parameter values were invalid: Aggregated size of all range keys has exceeded the size limit of 1024 bytes

# on DynamoDB Local you get one combined sentence instead, naming neither key:
ValidationException: Hash primary key values must be under 2048 bytes, and range primary key values must be under 1024 bytes

(Yes, the missing space in "of2048" is in the service's actual message.) Key attributes are indexed and physically partitioned by DynamoDB, so their length is bounded far below the 400 KB item limit. The partition key value must be 1 to 2048 bytes and the sort key value 1 to 1024 bytes. The byte count is the encoded size (UTF-8 for strings, raw bytes for binary) — multi-byte characters count for more than one. It's an HTTP 400 ValidationException, client-side, not retryable until the key shrinks.

Why it happens

  • A long string as the partition key — a URL, full document, encoded blob, or concatenated composite key used directly as the key value.
  • A verbose composite sort key — many segments joined with # that together exceed 1024 bytes.
  • Base64 / serialized data in a key — encoding inflates the byte count past the limit.
  • Multi-byte text — non-ASCII content whose UTF-8 encoding is larger than the character count suggests.

How to fix it

  1. Hash the long value — store a deterministic digest (e.g. SHA-256, ~32 bytes) as the key and keep the full value in a separate non-key attribute.
  2. Choose a more compact key — a shorter natural identifier instead of the bulky field.
  3. Shorten the composite key — trim or abbreviate the segments that make up a #-joined sort key.
  4. Move oversized content out of the key into a regular attribute (which only has to fit the 400 KB item limit).
  5. Count UTF-8 bytes, not characters. Emoji and CJK text expand quickly — a 500-character string can exceed 2048 bytes.

Connect from DynoTable

Paste draft key values into the item size calculator and check byte counts against the 2048/1024 limits before you write. In DynoTable, staging (⌘S) catches oversized keys on test items opened with ⌘K.

When shortening composite keys, prototype queries in the Query Builder. Switch profiles with ⌘P; Test Connection on Settings → Profiles. See Connect to AWS and Install.

Sources

References

Last verified 2026-07-13 against the official AWS documentation linked above.

Work with DynamoDB without the Console

A fast DynamoDB desktop client that runs the real SQL DynamoDB can’t — JOINs, GROUP BY, aggregates — with visual editing and an AI agent on your own Bedrock keys.

Free 30-day trial, no credit card — then the Free plan with no time limit.