If you don’t have Homebrew then go ahead and install it:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then install telnet:
brew install telnet
Example of usage:
telnet google.com 80
Output:
Trying 142.250.180.238…
Connected to google.com.
Escape character is ‘^]’.
Instead of telnet you can use nc (netcat)command
Example:
nc -v google.com 80
Output:
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 142.250.191.110:80.
Source: https://osxdaily.com/2018/07/18/get-telnet-macos/