What Are the Conditions of Joking in Islam?
Question

What are the conditions of permissible joking?
Praise be to Allah.The conditions of joking are:

Joking should not involve any element of making fun of Islam . 

That is one of the things that nullify a person’s Islam. Allah says (interpretation of the meaning): 
“If you ask them (about this), they declare: ‘We were only talking idly and joking.’ Say: ‘Was it at Allah, and His Ayat (proofs, evidences, verses, lessons, signs, revelations, etc.) and His Messenger  that you were mocking?’ Make no excuse; you disbelieved after you had believed” [Al-Tawbah 9:65-66]
Ibn Taymiyah (may Allah have mercy on him) said:
“Making fun of Allah , His Signs and His Messenger is disbelief and the one who does that disbelieves thereby after he had believed.” 
The same applies to making fun of some Sunnahs, an action which is widespread, such as making fun of the beard and the hijab, or of shortening one’s garment, etc. 
Shaykh Muhammad ibn ‘Uthaymin said in al-Majmu’ al-Thameen, 1/63:
 “The matters of Divine Lordship, Prophethood, Revelation and religion are sacred matters which are to be venerated. It is not permissible for anyone to show disrespect towards them, whether by mocking them to make others laugh or to poke fun at them. If anyone does that, he is a kafir, because this is indicative of his disrespect towards Allah and His messengers, Books and Laws. Whoever does that has to repent to Allah for what he has done, because that is a kind of hypocrisy. So he has to repent to Allah, seek His forgiveness, mend his ways and develop fear of Allah, veneration towards Him and love for Him in his heart. And Allah is the Source of strength.”

The jokes should only be truthful. 

The Prophet (peace and blessings of Allah be upon him) said: “Woe to the one who tells lies to make people laugh, woe to him.” (Narrated by Abu Dawud) 
The Prophet (peace and blessings of Allah be upon him) warned against this kind of behaviour which some jokers are accustomed to: “A man may say something to make his companions laugh, and he will fall into Hell as far as the Pleiades because of it.” (Narrated by Ahmad). 

You should not scare people. 

Especially those who are very energetic or strong, or who are holding a weapon or a piece of iron, or who take advantage of the darkness and people’s weakness to use that as a means of scaring and alarming them. It was narrated that Abu Layla said: “The Companions of Muhammad (peace and blessings of Allah be upon him) said that they were travelling with the Prophet (peace and blessings of Allah be upon him), and a man among them fell asleep. Some of them got a rope and tied him up, and he got scared. The Messenger of Allah (peace and blessings of Allah be upon him) said: ‘It is not permissible for a Muslim to frighten another Muslim.’” (Narrated by Abu Dawud) 

You should not mock people by winking behind their backs or making snide remarks. 

People vary in their ability to understand things and in their characters. Some weak people, those who like to make fun of others and wink behind their backs or make snide remarks, may find a person to be an object of fun for them and the butt of their jokes – Allah forbid. Allah has forbidden such behaviour in the ayah (interpretation of the meaning): 
“O you who believe! Let not a group scoff at another group, it may be that the latter are better than the former. Nor let (some) women scoff at other women, it may be that the latter are better than the former. Nor defame one another, nor insult one another by nicknames. How bad is it to insult one’s brother after having Faith.” [Al-Hujurat 49:11]
Ibn Kathir said in his Tafsir: 
“What is meant here is looking down on them, belittling them or making fun of them. This is haram and is counted as one of the characteristics of the hypocrites.” 
Some people make fun of a person’s appearance, manner of walking or vehicle. But there is the fear that Allah may requite the one who makes fun of others because of that. The Prophet (peace and blessings of Allah be upon him) said, “Do not express malicious joy towards your brother’s misfortune, for Allah may have mercy on him and you may be stricken by the thing you made fun of.” (Narrated by al-Tirmidhi) 
The Prophet (peace and blessings of Allah be upon him) warned against mocking people and hurting their feelings, because that is the path that leads to hatred and grudges. He (peace and blessings of Allah be upon him) said: “The Muslim is the brother of another Muslim, he does not wrong him, let him down or look down upon him. Taqwa (piety, awareness and fear of Allah) is here” – and he pointed to his chest three times – “It is sufficient evil for a man to look down upon his Muslim brother. Every Muslim is sacred to another Muslim, his blood, his property and his honour.” (Narrated by Muslim) 

The jokes should not be excessive. 

Some people joke too much and it becomes a habit for them. This is the opposite of the serious nature which is the characteristic of the believers. Joking is a break, a rest from ongoing seriousness and striving; it is a little relaxation for the soul. ‘Umar ibn ‘Abd al-‘Aziz (may Allah have mercy on him) said: “Fear joking, for it is folly and generates grudges.” 
Imam al-Nawawi (may Allah have mercy on him) said: “The kind of joking which is forbidden is that which is excessive and persistent, for it leads to too much laughter and hardening of the heart, it distracts from remembrance of Allah, and it often leads to hurt feelings, generates hatred and causes people to lose respect and dignity. But whoever is safe from such dangers, then that which the Messenger of Allah (peace and blessings of Allah be upon him) used to do is permissible for him.” 

You should acknowledge people’s status. 

Some people may joke with everyone indiscriminately, but scholars and the elderly have rights, so you have to be aware of the character of the person with whom you are dealing. You should not joke with ignorant people, fools or people whom you do not know. 
With regard to this matter, ‘Umar ibn ‘Abd al-‘Aziz said: “Fear joking, for it undermines chivalry and manliness.” 
Sa’d ibn Abi Waqqas said: “Set a limit to your jokes, for going to extremes makes you lose respect and incites the foolish against you.” 

The amount of joking should be like the amount of salt in one’s food. 

The Prophet (peace and blessings of Allah be upon him) said: “Do not laugh too much, for laughing too much deadens the heart.” (Sahih al-Jami’, 7312) 
‘Umar ibn al-Khattab (may Allah be pleased with him) said: “Whoever laughs too much or jokes too much loses respect, and whoever persists in doing something will be known for it.” 
So beware of joking, for it “causes a person to lose face after he was thought of as respectable, and it brings him humiliation after esteem.” 

Joking should not involve backbiting. 

This is a foul sickness. Some people think that they can talk about others, and say that this is by way of joking, but it is included in the hadith of the Prophet (peace and blessings of Allah be upon him), “[Backbiting is] your mentioning about your brother something that he dislikes.” (Narrated by Muslim) 

You should choose appropriate times for joking. 

Such as when you are taking a trip in the countryside, or attending a party in the evening, or when meeting a friend, you may relax and enjoy some gentle anecdotes, nice stories or light jokes, in order to generate friendship and instill happiness in the heart; or when family problems are taking their toll and one of the spouses is angry, some gentle joking may relieve the tension and cheer people up. 
A man said to Sufyan ibn ‘Uyaynah (may Allah be pleased with him), “Joking is not right, it is to be denounced.” He replied, “Rather it is Sunnah, but only for those who know how to do it and do it at the appropriate time.”  
Nowadays, although the ummah needs to increase the love between its individual members and to relieve itself of boredom, it has gone too far with regard to relaxation, laughter and jokes. This has become a habit which fills their gatherings and wastes their time, so their lives are wasted and their newspapers are filled with jokes and trivia. 
The Prophet (peace and blessings of Allah be upon him) said: “If you knew what I know, you would laugh little and weep much.” In Fath al-Bari it says: “What is meant by knowledge here has to do with the might of Allah and His vengeance upon those who disobey Him, and the terrors that occur at death, in the grave and on the Day of Resurrection). 
Muslim men and women have to be inclined to choose righteous and serious friends in their lives, who will help them to make good use of their time and strive for the sake of Allah with seriousness and steadfastness, good and righteous people whose example they can follow. Bilal ibn Sa’d said: “I saw them [the Sahabah] jokingly pretending to fight over some goods, and laughing with one another, but when night came they were like monks.” 
Ibn ‘Umar (may Allah be pleased with him) was asked, “Did the Companions of the Prophet (peace and blessings of Allah be upon him) laugh?” He said, “Yes, and the faith in their hearts was like mountains.” 
So you have to follow the example of such people, who were knights by day and monks (i.e., devoted worshippers) by night. 
May Allah keep us, you and our parents safe on the Day of the Greatest Terror, those to whom the call will go out on that great Day: 
“Enter Paradise, no fear shall be on you, nor shall you grieve.” [Al-A’raf 7:49 – interpretation of the meaning]
May Allah bless our Prophet Muhammad and all his family and Companions. 
And Allah knows best.