How do I programmatically get the field type of a specific field? I'm able to get a list of the field types with the following code.

$defs = \Drupal::service('plugin.manager.field.field_type')-&gt;getDefinitions();


I want to get the field type of a specific field. How do I get it?

For example, I'd like to check if the field type of field_image is _image. Is there code similar to the following one?

$fieldType = \Drupal::service('plugin.manager.field.field_type')-&gt;getDefinition('field_image');
With "get the field type of a specific field" you probably mean a specific field of an entity. There can be fields with the same name that have different types in different entities.

For example the field type of a field in a node: 

$field_type = $node-&gt;get($field_name)-&gt;getFieldDefinition()-&gt;getType();


can be different than that of the same field in a comment:

$field_type = $comment-&gt;get($field_name)-&gt;getFieldDefinition()-&gt;getType();