Drupal - How can I get the taxonomy term name from a term ID?

Or you can simply use The entity Term class:

use Drupal\taxonomy\Entity\Term;

and in your code:

$term = Term::load($tid);
$name = $term->getName();

The correct code is the following one.

$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid);

The entity type is taxonomy_term, not taxonomy.

Then, use $term->getName().


 $term_name = \Drupal\taxonomy\Entity\Term::load($term_id)->get('name')->value;

You will get the Term Name