Programmatically create a Custom Content type on saving a form We have explored it and found - how to create a content type by adding the YML files in the config/install directory of a custom module. The new content type will be created when we enable the module.

But we have a use case where we need to generate content types on saving a form.
For eg: We have a custom form with a field called "Content-Type Name". On submitting the form, we need to create a new content type with that name. 

We are not able to find any proper documentation for this in Drupal 8.
A content type is a config entity, you can create one like any other config entity (*):

$content_type = \Drupal\node\Entity\NodeType::create([
  'type' =&gt; $machine_name,
  'label' =&gt; $label,
]);
$content_type-&gt;save();