1 John 1:9 “If we confess our sins, he is faithful and just to forgive us our sins, and to cleanse us from all unrighteousness.”
This is not confession for salvation, but to escape chastisement.
John wrote this to Christians, not lost people. He even included himself in verse 8 “If we say that we have no sin, we deceive ourselves, and the truth is not in us.”
John made it plain here that even though he was saved he still had sin that he needed to confess to God and be cleansed of at times.
What does it mean to confess your sins?
The word confess in 1 John 1:9 means to to assent, that is, covenant, acknowledge, and it means to promise (Strong’s Exhaustive Concordance of the Bible with Greek and Hebrew dictionaries # 3670 in the Greek). Furthermore it roots back to another word meaning to remove and work (Strong’s Exhaustive Concordance of the Bible with Greek and Hebrew dictionaries # 3670 in the Greek).
Therefore, confessing your sins means that you acknowledge that you have sinned and you promise God that you will work to not do the sin again.
Confession includes true repentance. It is not asking forgiveness, and then going and doing the sin again and then asking forgiveness again. That kind of confession does not cleanse you from sin.
You must promise God that you will work to stop doing the sin. Yes, the Holy Spirit helps us to overcome sin, but it still takes effort on our part too.
If we judge ourselves then God will not judge us.
1 Corinthians 11:31-32 “For if we would judge ourselves, we should not be judged.” But when we are judged, we are chastened of the Lord, that we should not be condemned with the world.”
1 John 1:9 is instructions for Christians on how to cleanse themselves from sin by confession (repentance) on a regular bases so that God does not chastise them. It is not instructions for lost people to escape hell.