Q:

Is it haram to visualize having sex?

Is it haram for an unmarried girl to think about having sex? By this I mean seeing herself having sex with a guy who she finds attractive and thinking about how it would feel if the were a married couple in bed. 

A:

Sexual fantasies, I would say, are not uncommon for Muslims. The only problem, for men especially, is that sexual fantasies may lead to something more, including masturbation, or even worse, committing zina. That being said however, having sexual fantasies is by no means a sin, as long as the person does not act upon it.

Sexual fantasies are among the thoughts that cross a person’s mind because it is something that is stored in the subconscious which is affected by the environment in which he lives and the scenes that he sees. These are thoughts that occur to most people, especially the youth, but they vary from one person to another with regard to their type, strength and effect.
“Allaah burdens not a person beyond his scope”
[al-Baqarah 2:286]
Source

Also,

It was narrated from Abu Hurayrah (may Allaah be pleased with him)
that the Prophet (peace and blessings of Allaah be upon him) said:
“Allaah has forgiven my ummah for whatever crosses their mind so long
as they do not speak of it or act upon it.” Narrated by al-Bukhaari
(2528) and Muslim (127).

Therefore, it is very important not to act upon a fantasy, whichever form it may be. So as long as the person is in control of the situation, it is not a sin.
Finally, take a look at this site that answers in more detail a very similar, if not the same, topic.

A:

that top answer is totally wrong its sad that is been voted as the most correct when it doesnt clarify the difference between passing thoughts and intentionally fantasising about having sex. when you continue to dwell on that image it will let lust into your heart and harm you spiritually so yeah its a sin. If shaitan cast the image in your imagination and you look at it or your nafs wandered to it, disengage for your own spiritual well being. when you continuely lust it builds up in your heart over time and weighs you down making you feel depressed... so leading you to a bigger sin is not the only harm in it at all. not sinning is about helping yourself.

A:

Assalamualaikum,
First of all, if the thoughts are un-intentional, or in dream, then its not your fault or not a sin at all. But if you intentionally visualize anything like that, then it should be avoided completely, as it can be first way towards Zina (as committing Zina's first step starts from thinking about it, which fuels your lust). So you should avoid anything, which fuels the lust.
If you want to visualizer about it that how it would feel, with intention to know that situation, its my personal opinion to avoid that too (unless you are 100% sure that you have control over yourself completely).
(Note: my opinions are based on very limited knowledged i have about islam, and i am not a scholar, i would recommend that you consult a scholar as well, in this case)
And Allah knows the best.

