How to create a node Drupal 8 programmatically

Drupal provides the features to create a node programmatically.

You can create a node to use this code.

$node = \Drupal\node\Entity\Node::create([

'type=> 'node_type', // The node entity bundle(Articles, Basic Page).

'langcode' => 'en',

'created' => $created_date,

'changed' => $created_date,

'uid' => 1, // The user ID.

'moderation_state' => 'published',

'title' => $title,

]);

$node->save();