diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp
index d08f925cc7a5860efffed6ff60f0d3e6d2aa1690..9df5fa6a2203857afef5431e98095926dc1f3bd0 100644
--- a/Marlin/Marlin_main.cpp
+++ b/Marlin/Marlin_main.cpp
@@ -6082,25 +6082,22 @@ void process_next_command() {
   // Skip spaces to get the numeric part
   while (*cmd_ptr == ' ') cmd_ptr++;
 
-  // The code must have a numeric value
-  bool code_is_good = false;
+  uint16_t codenum = 0; // define ahead of goto
 
-  int codenum = 0; // define ahead of goto
+  // Bail early if there's no code
+  bool code_is_good = NUMERIC(*cmd_ptr);
+  if (!code_is_good) goto ExitUnknownCommand;
 
   // Get and skip the code number
-  while (*cmd_ptr >= '0' && *cmd_ptr <= '9') {
-    code_is_good = true;
-    codenum = codenum * 10 + *cmd_ptr - '0';
+  do {
+    codenum = (codenum * 10) + (*cmd_ptr - '0');
     cmd_ptr++;
-  }
-
-  // Bail early if there's no code
-  if (!code_is_good) goto ExitUnknownCommand;
+  } while (NUMERIC(*cmd_ptr));
 
-  // Skip all spaces to get to the first argument
+  // Skip all spaces to get to the first argument, or nul
   while (*cmd_ptr == ' ') cmd_ptr++;
 
-  // The command's arguments start here, for sure!
+  // The command's arguments (if any) start here, for sure!
   current_command_args = cmd_ptr;
 
   KEEPALIVE_STATE(IN_HANDLER);