Hide tokens in previous commits

I want to make my project public on GitHub, however my private tokens exist in prior commits and I don’t want those to become public of course, is there a way for me to hide them?

In principle: Rewrite the history to remove them, see Git - Rewriting History.

However, after that’s done the old commits will still be in the GitHub cache. To get rid of them you have to ask support to flush that data, as described in Removing sensitive data from a repository - GitHub Docs. That article also describes ways to remove the commits.