How did Nathanael know that Jesus was the Son of God?

Because before he called Philip, Jesus saw Nathanael sitting under a fig tree

Nathanael saith unto him, Whence knowest thou me? Jesus answered and said unto him, Before that Philip called thee, when thou wast under the fig tree, I saw thee.

Nathanael answered and saith unto him, Rabbi, thou art the Son of God; thou art the King of Israel. John 1:48-49