A YAML typo in a netplan file can lock you out when you apply it. The generate step catches many of those first.
sudo netplan generate
sudo netplan --debug generate
netplan generate reads the YAML in /etc/netplan, /lib/netplan and /run/netplan and writes the configuration for the backend (networkd or NetworkManager). It does not apply anything to the live interfaces, so it is a safe way to catch YAML mistakes. --debug prints extra output while it runs. A file that passes can still be wrong in content, such as a bad gateway, so follow it with netplan try on remote machines.
Further reading: netplan generate