diff --git a/src/common/src/config.rs b/src/common/src/config.rs
index d4b9501d6e0d4..083a8b77b4f33 100644
--- a/src/common/src/config.rs
+++ b/src/common/src/config.rs
@@ -2379,12 +2379,15 @@ pub struct CompactionConfig {
 
 #[cfg(test)]
 mod tests {
+    use risingwave_license::LicenseKey;
+
     use super::*;
 
     fn default_config_for_docs() -> RwConfig {
-        // Although we have `license_key` default to a test-only value in the code,
-        // it gets redacted during serialization, so we don't need to do anything special here.
-        RwConfig::default()
+        let mut config = RwConfig::default();
+        // Set `license_key` to empty in the docs to avoid any confusion.
+        config.system.license_key = Some(LicenseKey::empty());
+        config
     }
 
     /// This test ensures that `config/example.toml` is up-to-date with the default values specified
diff --git a/src/license/src/key.rs b/src/license/src/key.rs
index 01d8ac313f791..65e726c6e8388 100644
--- a/src/license/src/key.rs
+++ b/src/license/src/key.rs
@@ -120,6 +120,11 @@ impl<'a> From<LicenseKeyRef<'a>> for LicenseKey {
 }
 
 impl LicenseKey {
+    /// Create an empty license key, which means no license key is set.
+    pub fn empty() -> Self {
+        Self(String::new())
+    }
+
     /// Convert to a reference.
     pub fn as_ref(&self) -> LicenseKeyRef<'_> {
         LicenseKey(self.0.as_ref())