Windows Registry Key and Value Size Limits
The Windows Registry operates under specific structural constraints that govern the maximum length of key names, value names, and data sizes. Understanding these limits is critical for developers and system administrators to avoid corruption, data truncation, or unexpected errors when querying and writing configuration data through the Registry Editor (Regedit) and Windows APIs.
Registry Key Name Limits
A registry key name represents a single branch or container inside the registry tree.
- Maximum Key Name Length: A single registry key name can contain up to 255 characters. This count applies to individual key names between backslashes, not the entire registry path.
- Maximum Tree Depth: The registry supports a hierarchy depth of up to 512 levels. However, standard Windows APIs and user-mode applications may experience limitations if the total path exceeds the standard system path length limits.
Registry Value Name Limits
A value name acts as the identifier for specific data stored under a registry key.
- Maximum Value Name Length: Windows allows value names up to 16,383 characters (or 260 characters in older legacy systems). Despite this high structural limit, standard convention recommends keeping value names short and descriptive to optimize query performance.
Registry Value Data Size Limits
The size of the actual data stored within a registry value depends on the underlying Windows architecture and storage mechanisms.
- Maximum Value Data Size: The technical limit for value data is constrained only by available system memory. Earlier versions of Windows imposed hard limits (typically 1 MB per value), but modern 64-bit systems permit substantially larger data payloads.
- Best Practice Threshold: While the structural limit is bound by available memory, storing values larger than 1.5 KB to 2 KB directly in the registry degrades performance. Microsoft recommends storing large data payloads as external files on the disk and referencing their file paths within the registry instead.