diff --git a/core/modules/contact/src/MessageForm.php b/core/modules/contact/src/MessageForm.php
index e59208376a..0c824c8f8c 100644
--- a/core/modules/contact/src/MessageForm.php
+++ b/core/modules/contact/src/MessageForm.php
@@ -10,6 +10,7 @@
 use Drupal\Core\Flood\FloodInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Language\LanguageManagerInterface;
+use Drupal\Core\Render\RendererInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -54,6 +55,13 @@ class MessageForm extends ContentEntityForm {
    */
   protected $dateFormatter;
 
+  /**
+   * The renderer.
+   *
+   * @var \Drupal\Core\Render\RendererInterface
+   */
+  protected $renderer;
+
   /**
    * Constructs a MessageForm object.
    *
@@ -67,17 +75,20 @@ class MessageForm extends ContentEntityForm {
    *   The contact mail handler service.
    * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
    *   The date service.
+   * @param \Drupal\Core\Render\RendererInterface $renderer
+   *   The renderer.
    * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
    *   The entity type bundle service.
    * @param \Drupal\Component\Datetime\TimeInterface $time
    *   The time service.
    */
-  public function __construct(EntityRepositoryInterface $entity_repository, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatterInterface $date_formatter, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
+  public function __construct(EntityRepositoryInterface $entity_repository, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatterInterface $date_formatter, RendererInterface $renderer, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
     parent::__construct($entity_repository, $entity_type_bundle_info, $time);
     $this->flood = $flood;
     $this->languageManager = $language_manager;
     $this->mailHandler = $mail_handler;
     $this->dateFormatter = $date_formatter;
+    $this->renderer = $renderer;
   }
 
   /**
@@ -90,6 +101,7 @@ public static function create(ContainerInterface $container) {
       $container->get('language_manager'),
       $container->get('contact.mail_handler'),
       $container->get('date.formatter'),
+      $container->get('renderer'),
       $container->get('entity_type.bundle.info'),
       $container->get('datetime.time')
     );
@@ -109,7 +121,13 @@ public function form(array $form, FormStateInterface $form_state) {
         '#theme_wrappers' => ['container__preview'],
         '#attributes' => ['class' => ['preview']],
       ];
-      $form['preview']['message'] = $this->entityTypeManager->getViewBuilder('contact_message')->view($message, 'full');
+
+      $message_preview = $this->entityTypeManager->getViewBuilder('contact_message')->view($message, 'full');
+
+      $form['preview']['message'] = [
+        '#type' => 'markup',
+        '#markup' => $this->renderer->render($message_preview)
+      ];
     }
 
     $form['name'] = [
