diff --git a/core/core.services.yml b/core/core.services.yml
index 76088786cd..2ddb545a49 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -544,6 +544,9 @@ services:
     parent: container.trait
     tags:
       - { name: plugin_manager_cache_clear }
+  entity.generator:
+    class: Drupal\Core\Entity\EntityGenerator
+    arguments: ['@entity_type.manager']
   entity_type.repository:
     class: Drupal\Core\Entity\EntityTypeRepository
     arguments: ['@entity_type.manager']
diff --git a/core/lib/Drupal/Core/Entity/EntityGenerator.php b/core/lib/Drupal/Core/Entity/EntityGenerator.php
new file mode 100644
index 0000000000..62c3791576
--- /dev/null
+++ b/core/lib/Drupal/Core/Entity/EntityGenerator.php
@@ -0,0 +1,95 @@
+<?php
+
+namespace Drupal\Core\Entity;
+
+use Drupal\Core\Config\Entity\ConfigEntityType;
+use Drupal\Core\Entity\Exception\EntityGeneratorMismatchException;
+use Drupal\Core\Entity\Exception\MissingEntityGeneratorHandlerException;
+
+/**
+ * An entity generator service object.
+ *
+ * Entity generator can generate any fieldable content entity and can generate
+ * configuration entities with an attached generator handler.
+ *
+ * @see \Drupal\Core\Entity\GeneratorHandlerInterface
+ *
+ * @ingroup entity_generator
+ */
+class EntityGenerator implements EntityGeneratorInterface {
+
+  /**
+   * The entity type manager.
+   *
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+   */
+  protected $entityTypeManager;
+
+  /**
+   * Constructs a new EntityGenerator.
+   *
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   *   The entity type manager.
+   */
+  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
+    $this->entityTypeManager = $entity_type_manager;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function generateFieldableEntity($entity_type_id, $bundle, array $values = []) {
+    $entityType = $this->entityTypeManager->getDefinition($entity_type_id);
+    if (!$entityType->entityClassImplements(FieldableEntityInterface::class)) {
+      throw new EntityGeneratorMismatchException("Provided entity type \"%s\" is not fieldable. Use \Drupal\Core\Entity\EntityGenerator::generateConfigurationEntity() instead", $entity_type_id);
+    }
+    $bundle_key = $entityType->getKey('bundle');
+    $values[$bundle_key] = $bundle;
+
+    // Allow custom entity generation per entity type.
+    if ($entityType->hasHandlerClass('generator')) {
+      /** @var \Drupal\Core\Entity\GeneratorHandlerInterface $generator */
+      $generator = $this->entityTypeManager->getHandler($entity_type_id, 'generator');
+      $entity = $generator->generate($values);
+    }
+    else {
+      // Bundle is already set, and id and revision should never be set.
+      $forbidden_keys = [
+        $entityType->getKey('id'),
+        $entityType->getKey('revision'),
+        $bundle_key
+      ];
+      $forbidden_keys = array_merge($forbidden_keys, array_keys($values));
+      // Fallback entity generation in case no custom generator is supplied.
+      /** @var \Drupal\Core\Entity\FieldableEntityInterface $entity */
+      $entity = $this->entityTypeManager->getStorage($entity_type_id)->create($values);
+      foreach ($entity as $field_name => $value) {
+        if (!in_array($field_name, $forbidden_keys)) {
+          $entity->get($field_name)->generateSampleItems();
+        }
+      }
+    }
+    return $entity;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function generateConfigurationEntity($entity_type_id, array $values = []) {
+    $definition = $this->entityTypeManager->getDefinition($entity_type_id);
+    if (!$definition instanceof ConfigEntityType) {
+      throw new EntityGeneratorMismatchException("Provided entity type \"%s\" is not a configuration entity. Use \Drupal\Core\Entity\EntityGenerator::generateFieldableEntity() instead", $entity_type_id);
+    }
+    // Allow custom entity generation per entity type.
+    /** @var \Drupal\Core\Entity\FieldableEntityInterface $entity */
+    if ($definition->hasHandlerClass('generator')) {
+      /** @var \Drupal\Core\Entity\GeneratorHandlerInterface $generator */
+      $generator = $this->entityTypeManager->getHandler($entity_type_id, 'generator');
+      return $generator->generate($values);
+    }
+    else {
+      throw new MissingEntityGeneratorHandlerException($entity_type_id);
+    }
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Entity/EntityGeneratorInterface.php b/core/lib/Drupal/Core/Entity/EntityGeneratorInterface.php
new file mode 100644
index 0000000000..94a81d2997
--- /dev/null
+++ b/core/lib/Drupal/Core/Entity/EntityGeneratorInterface.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Drupal\Core\Entity;
+
+
+/**
+ * An entity generator service object.
+ *
+ * Entity generator can generate any fieldable content entity and can generate
+ * configuration entities with an attached generator handler.
+ *
+ * @see \Drupal\Core\Entity\GeneratorHandlerInterface
+ *
+ * @ingroup entity_generator
+ */
+interface EntityGeneratorInterface {
+
+  /**
+   * Generates a fieldable entity.
+   *
+   * @param string $entity_type_id
+   *   The entity type ID.
+   * @param string $bundle
+   *   The entity bundle.
+   * @param array $values
+   *   Any default values to use during generation.
+   *
+   * @return \Drupal\Core\Entity\FieldableEntityInterface
+   *   A fieldable content entity.
+   *
+   * @throws \Exception
+   *   Thrown if the chosen entity type is not a content entity.
+   */
+  public function generateFieldableEntity($entity_type_id, $bundle, array $values = []);
+
+  /**
+   * Generates a configuration entity.
+   *
+   * @param string $entity_type_id
+   *   The entity type ID.
+   * @param array $values
+   *   Any default values to use during generation.
+   *
+   * @return \Drupal\Core\Entity\EntityInterface
+   *   The generated entity.
+   *
+   * @throws \Exception
+   */
+  public function generateConfigurationEntity($entity_type_id, array $values = []);
+
+}
diff --git a/core/lib/Drupal/Core/Entity/Exception/EntityGeneratorMismatchException.php b/core/lib/Drupal/Core/Entity/Exception/EntityGeneratorMismatchException.php
new file mode 100644
index 0000000000..43f047b658
--- /dev/null
+++ b/core/lib/Drupal/Core/Entity/Exception/EntityGeneratorMismatchException.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Drupal\Core\Entity\Exception;
+
+/**
+ * Exception thrown when mismatched entity type is passed.
+ *
+ * Generators can create configuration or content entities, but have unique
+ * methods for each. This exception is thrown when a config entity type is
+ * passed to content entity generator method and vice versa.
+ *
+ * @see \Drupal\Core\Entity\EntityGenerator::generateFieldableEntity
+ * @see \Drupal\Core\Entity\EntityGenerator::generateConfigurationEntity
+ */
+class EntityGeneratorMismatchException extends \Exception {
+
+  /**
+   * Constructs an EntityGeneratorMismatchException.
+   *
+   * @param string $entity_type_id
+   *   The entity ID.
+   */
+  public function __construct($message, $entity_type_id) {
+    $message = sprintf($message, $entity_type_id);
+    parent::__construct($message);
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Entity/Exception/MissingEntityGeneratorHandlerException.php b/core/lib/Drupal/Core/Entity/Exception/MissingEntityGeneratorHandlerException.php
new file mode 100644
index 0000000000..59540dedf9
--- /dev/null
+++ b/core/lib/Drupal/Core/Entity/Exception/MissingEntityGeneratorHandlerException.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Drupal\Core\Entity\Exception;
+
+/**
+ * Exception thrown when config entity type has no generator handler.
+ *
+ * Content entities have a fallback generator in the EntityGenerator class but
+ * configuration entities cannot be reliably generated programmatically. To
+ * solve this they expect an entity generator handler to be attached to their
+ * plugin definition.
+ *
+ * @see \Drupal\Core\Entity\EntityGenerator::generateConfigurationEntity
+ */
+class MissingEntityGeneratorHandlerException extends \Exception {
+
+  /**
+   * Constructs an MissingEntityGeneratorHandlerException.
+   *
+   * @param string $entity_type_id
+   *   The entity ID.
+   */
+  public function __construct($entity_type_id) {
+    parent::__construct(sprintf("Missing generator handler. The \"%s\" entity type cannot be generated", $entity_type_id));
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Entity/GeneratorHandlerInterface.php b/core/lib/Drupal/Core/Entity/GeneratorHandlerInterface.php
new file mode 100644
index 0000000000..140be68491
--- /dev/null
+++ b/core/lib/Drupal/Core/Entity/GeneratorHandlerInterface.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Drupal\Core\Entity;
+
+/**
+ * Interface for entity generator handlers.
+ *
+ * Entity generator handlers generate a specific entity type. Most generators
+ * are only useful for configuration entities since fieldable content entities
+ * have a default built into core.
+ *
+ * @see \Drupal\Core\Entity\EntityGenerator
+ *
+ * @ingroup entity_generator
+ */
+interface GeneratorHandlerInterface {
+
+  /**
+   * Generate an entity of the type to which the handler is attached.
+   *
+   * @param array $values
+   *   An array of values to include as part of the entity.
+   *
+   * @return \Drupal\Core\Entity\EntityInterface
+   */
+  public function generate(array $values = []);
+
+}
diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php
index a1a1ebdb9e..5d13a5e5cc 100644
--- a/core/lib/Drupal/Core/Field/FieldItemList.php
+++ b/core/lib/Drupal/Core/Field/FieldItemList.php
@@ -259,7 +259,7 @@ public function view($display_options = []) {
    */
   public function generateSampleItems($count = 1) {
     $field_definition = $this->getFieldDefinition();
-    $field_type_class = \Drupal::service('plugin.manager.field.field_type')->getPluginClass($field_definition->getType());
+    $field_type_class = $field_definition->getItemDefinition()->getClass();
     for ($delta = 0; $delta < $count; $delta++) {
       $values[$delta] = $field_type_class::generateSampleValue($field_definition);
     }
diff --git a/core/modules/node/src/Entity/NodeType.php b/core/modules/node/src/Entity/NodeType.php
index e4a4c3b6c1..d671c0e147 100644
--- a/core/modules/node/src/Entity/NodeType.php
+++ b/core/modules/node/src/Entity/NodeType.php
@@ -20,6 +20,7 @@
  *       "delete" = "Drupal\node\Form\NodeTypeDeleteConfirm"
  *     },
  *     "list_builder" = "Drupal\node\NodeTypeListBuilder",
+ *     "generator" = "Drupal\node\NodeTypeGenerator"
  *   },
  *   admin_permission = "administer content types",
  *   config_prefix = "type",
diff --git a/core/modules/node/src/NodeTypeGenerator.php b/core/modules/node/src/NodeTypeGenerator.php
new file mode 100644
index 0000000000..5639de60c2
--- /dev/null
+++ b/core/modules/node/src/NodeTypeGenerator.php
@@ -0,0 +1,54 @@
+<?php
+
+
+namespace Drupal\node;
+
+
+use Drupal\Component\Utility\Random;
+use Drupal\Core\Entity\GeneratorHandlerInterface;
+use Drupal\node\Entity\NodeType;
+
+class NodeTypeGenerator implements GeneratorHandlerInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function generate(array $values = []) {
+    $generated_values = [
+      'type' => $this->getSampleSentence(1),
+      'name' => $this->getSampleSentence(1),
+      'description' => $this->getSampleSentence(),
+      'help' => $this->getSampleSentence(),
+      'new_revision' => $this->getBoolean(),
+      'preview_mode' => $this->getPreviewMode(),
+      'display_submitted' => $this->getBoolean(),
+    ];
+    $values = array_merge($generated_values, $values);
+    return NodeType::create($values);
+  }
+
+  protected function getSampleSentence($words = NULL) {
+    $random = new Random();
+    $words = $words ? $words : mt_rand(10, 20);
+    $text = "";
+    for ($i = 0; $i < $words; $i++) {
+      $text .= $random->word(mt_rand(2, 7)) . ' ';
+    }
+    return $text;
+  }
+
+  protected function getPreviewMode() {
+    $options = [
+      DRUPAL_DISABLED,
+      DRUPAL_OPTIONAL,
+      DRUPAL_REQUIRED,
+    ];
+    $key = rand(0, 2);
+    return $options[$key];
+  }
+
+  protected function getBoolean() {
+    return (bool) rand(0, 1);
+  }
+
+}
\ No newline at end of file
diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php
index 7529532581..f254ccff93 100644
--- a/core/modules/user/src/Entity/User.php
+++ b/core/modules/user/src/Entity/User.php
@@ -9,6 +9,7 @@
 use Drupal\Core\Field\BaseFieldDefinition;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\user\RoleInterface;
+use Drupal\user\TimeZoneItem;
 use Drupal\user\UserInterface;
 
 /**
@@ -498,6 +499,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
       ->addPropertyConstraints('value', [
         'AllowedValues' => ['callback' => __CLASS__ . '::getAllowedTimezones'],
       ]);
+    $fields['timezone']->getItemDefinition()->setClass(TimeZoneItem::class);
 
     $fields['status'] = BaseFieldDefinition::create('boolean')
       ->setLabel(t('User status'))
diff --git a/core/modules/user/src/TimeZoneItem.php b/core/modules/user/src/TimeZoneItem.php
new file mode 100644
index 0000000000..d893b115ff
--- /dev/null
+++ b/core/modules/user/src/TimeZoneItem.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Drupal\user;
+
+
+use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Core\Field\Plugin\Field\FieldType\StringItem;
+use Drupal\user\Entity\User;
+
+/**
+ * Defines a custom field item class for the 'timezone' user entity field.
+ */
+class TimeZoneItem extends StringItem {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
+    $timezones = User::getAllowedTimezones();
+    // We need to vary the selected timezones since we're generating a sample.
+    $key = rand(0, count($timezones));
+    return $timezones[$key];
+  }
+
+}
diff --git a/core/modules/user/src/UserNameItem.php b/core/modules/user/src/UserNameItem.php
index 6a53eb5d06..e6a0f2d420 100644
--- a/core/modules/user/src/UserNameItem.php
+++ b/core/modules/user/src/UserNameItem.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\user;
 
+use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\Plugin\Field\FieldType\StringItem;
 
 /**
@@ -23,4 +24,14 @@ public function isEmpty() {
     return $value === NULL || $value === '';
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
+    $values = parent::generateSampleValue($field_definition);
+    // User names larger than 60 characters won't pass validation.
+    $values['value'] = substr($values['value'], 0, UserInterface::USERNAME_MAX_LENGTH);
+    return $values;
+  }
+
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityGeneratorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityGeneratorTest.php
new file mode 100644
index 0000000000..0bd30c1434
--- /dev/null
+++ b/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityGeneratorTest.php
@@ -0,0 +1,129 @@
+<?php
+
+
+namespace Drupal\KernelTests\Core\Entity\Element;
+
+use Drupal\Core\Entity\ContentEntityType;
+use Drupal\Core\Entity\Exception\EntityGeneratorMismatchException;
+use Drupal\Core\Entity\Exception\MissingEntityGeneratorHandlerException;
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\node\Entity\NodeType;
+use Drupal\taxonomy\Entity\Vocabulary;
+
+/**
+ * Tests the EntityGenerator API.
+ *
+ * @coversDefaultClass \Drupal\Core\Entity\EntityGenerator
+ * @group Entity
+ */
+class EntityGeneratorTest extends KernelTestBase {
+
+  /**
+   * The entity type manager.
+   *
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+   */
+  protected $entityTypeManager;
+
+  /**
+   * The entity generator.
+   *
+   * @var \Drupal\Core\Entity\EntityGenerator
+   */
+  protected $entityGenerator;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['system', 'field', 'filter', 'text', 'file', 'user', 'node', 'comment', 'taxonomy'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setup();
+
+    $this->installEntitySchema('file');
+    $this->installEntitySchema('user');
+    $this->installEntitySchema('node');
+    $this->installEntitySchema('node_type');
+    $this->installEntitySchema('file');
+    $this->installEntitySchema('comment');
+    $this->installEntitySchema('comment_type');
+    $this->installEntitySchema('taxonomy_vocabulary');
+    $this->installEntitySchema('taxonomy_term');
+    $this->entityTypeManager = $this->container->get('entity_type.manager');
+    $this->entityGenerator = $this->container->get('entity.generator');
+    NodeType::create(['type' => 'article', 'name' => 'Article'])->save();
+    NodeType::create(['type' => 'page', 'name' => 'Page'])->save();
+    Vocabulary::create(['name' => 'Tags', 'vid' => 'tags'])->save();
+  }
+
+  /**
+   * Tests generation of all enabled content entity types.
+   *
+   * * @covers ::generateFieldableEntity
+   */
+  public function testGenerateContentEntity() {
+    foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $definition) {
+      if ($definition instanceof ContentEntityType) {
+        // Generate entities with bundles.
+        if ($bundle_type = $definition->getBundleEntityType()) {
+          foreach ($this->entityTypeManager->getStorage($bundle_type)->loadMultiple() as $bundle) {
+            $entity = $this->entityGenerator->generateFieldableEntity($entity_type_id, $bundle->id());
+            $violations = $entity->validate();
+            $this->assertEquals(0, $violations->count());
+          }
+        }
+        // Generate entities without bundles.
+        else {
+          $entity = $this->entityGenerator->generateFieldableEntity($entity_type_id, $entity_type_id);
+          $violations = $entity->validate();
+          $this->assertEquals(0, $violations->count());
+        }
+      }
+    }
+    $this->setExpectedException(EntityGeneratorMismatchException::class, "Provided entity type \"node_type\" is not fieldable. Use \Drupal\Core\Entity\EntityGenerator::generateConfigurationEntity() instead");
+    $this->entityGenerator->generateFieldableEntity('node_type', 'page');
+  }
+
+  /**
+   * Tests generation of configuration entity types.
+   *
+   * @covers ::generateConfigurationEntity
+   */
+  public function testGenerateConfigEntity() {
+    /** @var \Drupal\node\Entity\NodeType $node_type */
+    $node_type = $this->entityGenerator->generateConfigurationEntity('node_type');
+    $this->assertTrue(is_string($node_type->id()));
+    $this->assertTrue(is_string($node_type->label()));
+    $this->assertTrue(is_string($node_type->getDescription()));
+    $this->assertTrue(is_string($node_type->getHelp()));
+    $this->assertTrue(is_bool($node_type->isNewRevision()));
+    $this->assertTrue(in_array($node_type->getPreviewMode(), [DRUPAL_DISABLED, DRUPAL_OPTIONAL, DRUPAL_REQUIRED]));
+    $this->assertTrue(is_bool($node_type->displaySubmitted()));
+    // Save it and make certain we don't throw an exception.
+    $this->assertTrue(is_int($node_type->save()));
+  }
+
+  /**
+   * Tests mismatched entity generator exception for config entities.
+   *
+   * @covers ::generateConfigurationEntity
+   */
+  public function testGeneratorMismatchException() {
+    $this->setExpectedException(EntityGeneratorMismatchException::class, "Provided entity type \"node\" is not a configuration entity. Use \Drupal\Core\Entity\EntityGenerator::generateFieldableEntity() instead");
+    $this->entityGenerator->generateConfigurationEntity('node');
+  }
+
+  /**
+   * Tests missing generator handler entity.
+   *
+   * @covers ::generateConfigurationEntity
+   */
+  public function testMissingGeneratorHandlerException() {
+    $this->setExpectedException(MissingEntityGeneratorHandlerException::class);
+    $this->entityGenerator->generateConfigurationEntity('taxonomy_vocabulary');
+  }
+
+}
