diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php
index 1dc3395161a21f420f3bcee57103ca37fe2d370b..1dc71fba01ebcd89838a8088811bf78844ef966c 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php
@@ -41,12 +41,10 @@ class FilterHtml extends FilterBase {
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $form['allowed_html'] = array(
-      '#type' => 'textfield',
+      '#type' => 'textarea',
       '#title' => $this->t('Allowed HTML tags'),
       '#default_value' => $this->settings['allowed_html'],
-      '#maxlength' => 2048,
       '#description' => $this->t('A list of HTML tags that can be used. By default only the <em>lang</em> and <em>dir</em> attributes are allowed for all HTML tags. Each HTML tag may have attributes which are treated as allowed attribute names for that HTML tag. Each attribute may allow all values, or only allow specific values. Attribute names or values may be written as a prefix and wildcard like <em>jump-*</em>. JavaScript event attributes, JavaScript URLs, and CSS are always stripped.'),
-      '#size' => 250,
       '#attached' => array(
         'library' => array(
           'filter/drupal.filter.filter_html.admin',
@@ -70,6 +68,12 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
    * {@inheritdoc}
    */
   public function setConfiguration(array $configuration) {
+    if (isset($configuration['settings']['allowed_html'])) {
+      // The javascript in core/modules/filter/filter.filter_html.admin.js
+      // removes new lines and double spaces so, for consistency when javascript
+      // is disabled, remove them.
+      $configuration['settings']['allowed_html'] = preg_replace('/\s+/', ' ', $configuration['settings']['allowed_html']);
+    }
     parent::setConfiguration($configuration);
     // Force restrictions to be calculated again.
     $this->restrictions = NULL;
diff --git a/core/modules/filter/src/Tests/FilterAdminTest.php b/core/modules/filter/src/Tests/FilterAdminTest.php
index e71b57ab45c4280197401462071577fac4150e5f..830cf18d77619ebc0e2041022178d3d5bfea04bc 100644
--- a/core/modules/filter/src/Tests/FilterAdminTest.php
+++ b/core/modules/filter/src/Tests/FilterAdminTest.php
@@ -206,13 +206,13 @@ function testFilterAdmin() {
     $this->assertTrue($full_format->access('use', $this->adminUser), 'Admin user may use Full HTML.');
     $this->assertFalse($full_format->access('use', $this->webUser), 'Web user may not use Full HTML.');
 
-    // Add an additional tag.
+    // Add an additional tag and extra spaces and returns.
     $edit = array();
-    $edit['filters[filter_html][settings][allowed_html]'] = '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <quote>';
+    $edit['filters[filter_html][settings][allowed_html]'] = "<a>   <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>\r\n<quote>";
     $this->drupalPostForm('admin/config/content/formats/manage/' . $restricted, $edit, t('Save configuration'));
     $this->assertUrl('admin/config/content/formats');
     $this->drupalGet('admin/config/content/formats/manage/' . $restricted);
-    $this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], 'Allowed HTML tag added.');
+    $this->assertFieldByName('filters[filter_html][settings][allowed_html]', "<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <quote>", 'Allowed HTML tag added.');
 
     $elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', array(
       ':first' => 'filters[' . $first_filter . '][weight]',
diff --git a/core/modules/filter/tests/src/Unit/FilterHtmlTest.php b/core/modules/filter/tests/src/Unit/FilterHtmlTest.php
index a3cde04e96d0e4874c1f01bfd6a9f8bac840c391..664c2a3001af991f8e45174e0e8c907b9ad56718 100644
--- a/core/modules/filter/tests/src/Unit/FilterHtmlTest.php
+++ b/core/modules/filter/tests/src/Unit/FilterHtmlTest.php
@@ -79,4 +79,18 @@ public function providerFilterAttributes() {
     ];
   }
 
+  /**
+   * @covers ::setConfiguration
+   */
+  public function testSetConfiguration() {
+    $configuration['settings'] = [
+      // New lines and spaces are replaced with a single space.
+      'allowed_html' => "<a>  <br>\r\n  <p>",
+      'filter_html_help' => 1,
+      'filter_html_nofollow' => 0,
+    ];
+    $filter = new FilterHtml($configuration, 'filter_html', ['provider' => 'test']);
+    $this->assertSame('<a> <br> <p>', $filter->getConfiguration()['settings']['allowed_html']);
+  }
+
 }