Yes, God is omniscient, so He knows everything. Everything. Some people use that as an reason not to pray. Yet it can also be an excellent reason to pray all the more. If He already knows everything you’ve done, said and thought yet has still forgiven you (assuming you are a Christian), then only good can come from sharing your deepest feelings with Him.
When we confess our sins, we aren’t telling God anything He didn’t already know. But we are saying that we now view our sins from his point of view and that we are turning from them.