How to clear image (or file) field data for specific node programmatically? I need to clear/remove image (or file) field from specific node.
I have before:

I want to get after code execution for the field:

What code should I use to properly clear image (file) field data?
I assume that your field accepts only one file at a time. This is the code you need to use:
// Replace this with the ID of the node you want to update.
$node_id = 123;

/** @var \Drupal\node\NodeInterface $node */
$node = \Drupal\node\Entity\Node::load($node_id);

// Step 1: remove the file. This will actually delete the file from the
// filesystem, so in case you want to keep it just remove the next two
// lines.
/** @var \Drupal\file\FileInterface $file */
$file = $node-&gt;get('field_NAME_OF_YOUR_FIELD')-&gt;entity;
$file-&gt;delete();

// Step 2: remove the field data.
// The 0 in this case is the index of the item you want to remove. It simply
// means the first value in that field needs to be removed.
$node-&gt;get('field_NAME_OF_YOUR_FIELD')-&gt;removeItem(0);
// We have to save the changes to the node.
$node-&gt;save();