Boyfriend doesn’t want to have sex

I don’t know what to do, I feel rejected and ugly and unwanted but I don’t want to pressure him or stress him out. We’ve been together 3 and half years, we’re in our mid 20s, our relationship is great (as far as I can tell at least) we’re loving and affectionate, we kiss and cuddle and all that lovey stuff. He just doesn’t want to have sex with me.

I just don’t get it and I don’t know what to do. I miss feeling like he wants me, like he’s attracted to me... he says that he is and that he does want me, he just isn’t interested in sex—- but he used to be, he used to want me all the time.

I’m scared mostly, scared this is heading in a bad direction, that he won’t just have lost interest in sex, but in being with me.

Any ideas on what to do or how to fix this? How to talk to him without upsetting him?