How do I alter the login form? I have used custom_module_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id); I get the form ID of other forms, but I don't get the login form $form_id inside the hook.
Try clearing cache and then visiting login page again, that should show Form ID. It will be hidden again when you refresh login page.

use \Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_alter().
 */
function [MODULE_NAME]_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  echo $form_id;
  switch ($form_id) {
    case 'user_login_form':
      // Do your code here to alter login form.
      break;
  }
}