diff --git a/core/modules/filter/src/Element/ProcessedText.php b/core/modules/filter/src/Element/ProcessedText.php
index a9505799b68717c254fa364149bfdca3a353b06f..ed73069fdca754e949277c75053412c48b5500f6 100644
--- a/core/modules/filter/src/Element/ProcessedText.php
+++ b/core/modules/filter/src/Element/ProcessedText.php
@@ -66,7 +66,7 @@ public function getInfo() {
   public static function preRenderText($element) {
     $format_id = $element['#format'];
     $filter_types_to_skip = $element['#filter_types_to_skip'];
-    $text = $element['#text'];
+    $text = is_string($element['#text']) ? $element['#text'] : '';
     $langcode = $element['#langcode'];
 
     if (!isset($format_id)) {
diff --git a/core/modules/filter/tests/src/Kernel/FilterAPITest.php b/core/modules/filter/tests/src/Kernel/FilterAPITest.php
index 4d50562b08f1421211181135dc374645d40d6e87..3123ed8676932819b8c9234ebb75abb1d69dbb88 100644
--- a/core/modules/filter/tests/src/Kernel/FilterAPITest.php
+++ b/core/modules/filter/tests/src/Kernel/FilterAPITest.php
@@ -320,6 +320,15 @@ public function testProcessedTextElement(): void {
     $this->assertEqualsCanonicalizing($expected_cache_contexts, $build['#cache']['contexts'], 'Expected cache contexts present.');
     $expected_markup = '<p>Hello, world!</p><p>This is a dynamic llama.</p><p>This is a static llama.</p>';
     $this->assertSame($expected_markup, (string) $build['#markup'], 'Expected #lazy_builder callback has been applied.');
+
+    // Confirm that NULL #text does not trigger PHP 8.1 deprecation message.
+    $build = [
+      '#type' => 'processed_text',
+      '#text' => NULL,
+      '#format' => 'filtered_html',
+    ];
+    \Drupal::service('renderer')->renderRoot($build);
+    $this->assertSame('', $build['#markup']);
   }
 
   /**
