Praise be to Allah.ؤ Praise be to Allaah.
If a fasting person needs to taste the food whilst fasting, there is nothing wrong with that, and it does not affect the fast so long as none of the food enters the throat of the fasting person. This applies equally to coffee and other things.
If he tastes it without any need to do so, this is makrooh, but it does not invalidate the fast.
Ibn ‘Abbaas said: There is nothing wrong with tasting what is being cooked or whatever. Narrated by al-Bukhaari in a mu’allaq report.
Imam Ahmad said: I prefer that he should avoid tasting food, but if he does that it will not affect him and there is nothing wrong with that. Al-Mughni, 4/359.
Shaykh al-Islam [Ibn Taymiyah] said in al-Fataawa al-Kubra (4/474):
Tasting food is makrooh if there is no need to do that, but it does not break the fast.
Shaykh Ibn ‘Uthaymeen was asked in Fataawa al-Siyaam (p. 356): Is the fast invalidated by tasting food?
He replied: The fast is not invalidated by tasting food so long as one does not swallow it, but you should not do that unless there is a need for it; in that case if a little of it reaches your stomach by accident your fast is not invalidated.
It says in Fataawa al-Lajnah al-Daa’imah (10/332):
There is nothing wrong with a person tasting food during the day when fasting, when there is a need to so that, and his fast is valid if he does not deliberately swallow any of it.
If the taste or smell remains, that does not affect the fast, so long as you do not deliberately swallow anything.
Ibn Sireen said: There is nothing wrong with using a wet siwaak – i.e., when fasting. It was said: It has a flavour. He said: And water has a flavour, but you rinse your mouth with it.
Shaykh Ibn ‘Uthaymeen said in al-Sharh al-Mumti’ (3/261):
It is makrooh to taste food such as dates, bread and soup, unless there is a need to do that, in which case it is o.k.
The reason for that is that some of this food may go down into the stomach without a person realizing, so tasting this food exposes him to spoiling the fast. Also he may be desiring the food a great deal, so he tastes it in order to enjoy it, and he may swallow it, then some of it goes down into his stomach.
Examples of necessity are when a cook needs to see how salty or sweet the food is, and so on.
Based on this: there is nothing wrong with tasting the coffee when you are fasting, because you need to do that. But you have to be very cautious and make sure that nothing reaches your stomach.
And Allaah knows best.