Bus
This is the cheapest option at 2 USD per trip. SamTrans buses pick up passengers from different airport terminals. KX/292/397/398 will pick you up near the international terminal on the first level (concourse A), while 140/292/397 will pick you up near the car rental center. For exact fares to different parts of the city and schedules, check here.
BART train
It takes you to downtown San Francisco. It departs from a station in the departure area of the international terminal. From other terminals, you can walk to this platform or take the AirTrain, which runs through the airport. The platform you need is Garage G/BART Station stop. The fare depends on the distance. Fares are listed on the website.
Taxi
If you have not arranged a transfer from the hotel, but want to get there with maximum comfort, take a cab. The easiest way to make an order from your smartphone is through the Uber system. You will quickly be served a clean car with a polite driver. You can also find a car near the exit. Tipping a cab driver is mandatory and amounts to 15% of the payment amount. Together with them, a trip to Union Square or Fisherman's Wharf will cost 40-50 USD.