Contrition may be either perfect or imperfect. While perfect contrition forgives all sins, imperfect contrition forgives only venial sins. The Catechism of the Catholic Church (1451-1453) explains:
Among the penitent’s acts contrition occupies first place. Contrition is sorrow of the soul and detestation for the sin committed, together with the resolution not to sin again.
When it arises from a love by which God is loved above all else, contrition is called ‘perfect’ (contrition of charity). Such contrition remits venial sins; it also obtains forgiveness of mortal sins if it includes the firm resolution to have recourse to sacramental confession as soon as possible.
The contrition called ‘imperfect’ (or ‘attrition’) is also a gift of God, a prompting of the Holy Spirit. It is born of the consideration of sin’s ugliness or the fear of eternal damnation and the other penalties threatening the sinner (contrition of fear). Such a stirring of conscience can initiate an interior process which, under the prompting of grace, will be brought to completion by sacramental absolution. By itself however, imperfect contrition cannot obtain the forgiveness of grave sins, but it disposes one to obtain forgiveness in the sacrament of Penance.
An act of contrition is an expression to God of the sorrow of the penitent. There is no required formula for this and it may be very simple such as “Lord Jesus, Son of God, have mercy on me, a sinner”. The Handbook of Prayers offers the following prayer (p. 62):
O my God, I am heartily sorry for having offended you, and I detest all my sins, because I dread the loss of heaven and the pains of hell; but most of all because they offend you, my God, who are all good and deserving of all my love. I firmly resolve, with the help of your grace, to confess my sins, to do penance, and to amend my life. Amen.