REG_SZ vs REG_EXPAND_SZ in Windows Registry

In the Windows Registry, both REG_SZ and REG_EXPAND_SZ are data types used to store character strings, but their primary difference lies in how they handle environment variables. While REG_SZ stores static text that applications read literally, REG_EXPAND_SZ contains an expandable string containing unexpanded references to environment variables (such as %SystemRoot% or %USERNAME%) that are dynamically resolved to their actual values when an application queries them.

What is REG_SZ?

REG_SZ stands for “Registry String Zero” (null-terminated string). It is the most common registry value type used for standard, fixed-length text data.

When you store a path or a string as a REG_SZ, the operating system and calling programs interpret the text exactly as written. For example, if a REG_SZ value is set to %SystemRoot%\System32, an application reading this key will receive the literal string "%SystemRoot%\System32", rather than resolving it to C:\Windows\System32.

What is REG_EXPAND_SZ?

REG_EXPAND_SZ stands for “Registry Expandable String Zero”. This type is designed specifically to hold text containing system or user environment variables enclosed in percent signs (%variable%).

When an application queries a REG_EXPAND_SZ value using standard Windows APIs (such as RegQueryValueEx combined with ExpandEnvironmentStrings), Windows automatically replaces the variable placeholders with their active, machine-specific values. For example, storing %USERPROFILE%\AppData will dynamically evaluate to C:\Users\Username\AppData depending on which user is currently logged in.

Key Differences at a Glance

Viewing and Editing in Regedit

Inside the Registry Editor (regedit.exe), both types appear as editable text fields displaying raw text. However, you cannot simply convert a REG_SZ entry into a REG_EXPAND_SZ entry by editing the text. To switch types, you must delete the existing value and recreate it with the correct type: String Value (REG_SZ) or Expandable String Value (REG_EXPAND_SZ).