How to duplicate nodes programmatically?
You can read the values from the original node in an array and create a new node with the data:

$storage = \Drupal::entityTypeManager()-&gt;getStorage('node');

$node = $storage-&gt;load($nid);

$original_values = $node-&gt;toArray();

// assign content type as string, the array causes an error when creating a new node
$original_values['type'] = $node-&gt;bundle();

// change title
$original_values['title'] = $node-&gt;label() . ' (cloned)';

// remove nid and uuid, the cloned node is assigned new ones when saved
unset($original_values['nid']);
unset($original_values['uuid']);

// remove revision data, the latest revision becomes the only one in the new node
unset($original_values['vid']);
unset($original_values['revision_translation_affected']);
unset($original_values['revision_uid']);
unset($original_values['revision_log']);
unset($original_values['revision_timestamp']);

$node_cloned = $storage-&gt;create($original_values);
$node_cloned-&gt;save();