$uid = \Drupal::currentUser()->id() // if you wan to get a username of the current user $account = \Drupal\user\Entity\User::load($uid); // pass your uid $username = $account->getUsername(); Tags All Drupal