First thing: you’re safe here. San Francisco is a safe city. No one wants to hurt you. No one wants to mug you. No one wants to hassle you or deliberately make you uncomfortable. (Well, sort of. More on that later.)
Let me address crime. The biggest problem is property theft, and most of that is breaking into cars and stealing what is on the seat. If you’re not driving (and you shouldn’t–it’s a freaking nightmare for newcomers to drive in San Francisco) then nothing will be stolen out of your car.
You do have to be aware of hanging your purse or backpack over a chair in a restaurant. People will take the opportunity to dip into it. Also on a crowded bus or streetcar.
So thieves want your stuff. They don’t want to hurt you–it’s too much trouble, and calls attention to them. Why hurt someone when if you’re patient you can easily steal a wallet from an open packpack? If you use common sense, and make it difficult for a thief to take your stuff, they’ll find someone else who isn’t paying attention.
San Francisco has homeless people, and panhandlers. The homeless, many of whom should be in treatment, are trying to survive on the street. They don’t want to bother you. Panhandlers (who are also usually homeless) will ask for spare change. You can ignore them, smile and say “Sorry,” or give them change. But whatever you do, they are not going to hurt you. Don’t be afraid of them.
Occasionally, if you are near Union Square, you might find yourself on or near a sketchy street. There might even be someone who looks like a drug dealer or prostitute. This might make you uncomfortable, and rightly so, but you’re not going to be hurt. They know you don’t want what they’re selling, and won’t bother you.
Last year, my wife and I were in Barcelona, made a turn and found ourselves on a sketchy street. The people on the street knew we did not want what they were selling, and had made a wrong turn. The most we got was an eye-roll. Uncomfortable, sure. Dangerous? Not at all. Same in San Francisco.
So, to sum up, you’re OK here. San Francisco is a city, and has the whole fabric of city people. It may be something you don’t experience back home. But honestly, you’re going to get hassled more by a drunk fratboy, or some idiot with an overblown sense of entitlement that thinks they can be rude to you, shove you out of the way in the crosswalk, or steal your seat at a bar, than some poor panhandler.