In 1 John 5:9-13, John says that we can know for sure that we’re saved by if we believe in Christ – not by if we have a changed life of less sin: “If we receive the witness of men, the witness of God is greater; for this is the witness of God which He has testified of His Son. He who believes in the Son of God has the witness in himself; he who does not believe God has made Him a liar, because he has not believed the testimony that God has given of His Son. And this is the testimony: that God has given us eternal life, and this life is in His Son. He who has the Son has life; he who does not have the Son of God does not have life. These things I have written to you who believe in the name of the Son of God, that you may know that you have eternal life, and that you may continue to believe in the name of the Son of God.
In Matthew 7:21-23 we can see that many will bring their works to show that they’re saved, ultimately to be rejected by having their faith in their works: “Not everyone who says to Me [Jesus], ‘Lord, Lord,’ shall enter the kingdom of heaven, but he who does the will of My Father [John 6:40 — the will of the Father is to believe in Jesus] in heaven. Many will say to Me in that day, ‘Lord, Lord, have we not prophesied in Your name [a work they bring], cast out demons in Your name [a work they bring], and done many wonders in Your name [works they bring]?’ And then will I profess unto them, I never knew you: depart from me, ye that work iniquity [the sin of unbelief].
It’s not by having a changed life, sinning less, being a better person, etc. It’s by faith alone in Christ (1 Corinthians 15:1-4).
You can’t see someone’s salvation. But you can know they’re saved by their testimony of faith alone in the gospel. Hebrews 11:1 — Now faith is the substance of things hoped for, the evidence of things not seen [their salvation].
One of the Holy Spirit’s jobs for the believer is to convict them of their imputed righteousness in Christ. The Holy Spirit convicts the unbelievers of their sin, in order to lead them to Christ for salvation: John 16:8-11 — And when He [The Holy Spirit] has come, He will convict the world of sin, and of righteousness, and of judgment: of sin, because they do not believe in Me [unbelievers convicted of sin]; of righteousness, because I go to My Father and you see Me no more [to remind the believer of their righteousness in Christ]; of judgment, because the ruler of this world [Satan] is judged.