Our words often get us into trouble. As James 3:8 says, it is a restless evil. But, merely keeping silent is not the answer either. Again, the book of Proverbs helps us maintain the godly, mature, and very wise balance.
In Proverbs 26:4-5, two parallel statements on answering another are given.
4 Answer not a fool according to his folly, lest you be like him yourself.
5 Answer a fool according to his folly, lest he be wise in his own eyes.
When another utters what is foolish, harmful, untrue, or unnecessary, you need to consider how you will answer. You can speak the truth in love (Ephesians 4:15) and be of great upbuilding to the individual, or you can decline into the same downward cycle of hurtful and tasteless counter-speech.
Remember these two proverbs – given side-by-side to us in the Word of God. If you perceive that your answer will merely make you as ungodly, foolish, and immature in speech as the other person was, then refrain from speaking. Wait for a better time. But if you perceive that it might be a good time, and you might be the right person to address the matter with your friend, then answer promptly so the other will be helped.
Search the book of Proverbs for words like “speech”, “tongue”, “words”, and “lips”. Group them by common thought. Accumulate for yourself wise sayings on saying things wisely.