The shooting was reported at about 2:45 a.m. in the 500 block of Hyde Street.
The 20-year-old victim was walking when he heard a pop and felt a sting to his left arm, according to police.
The victim then found a pellet in his jacket and saw a welt on his arm, police said. He was taken to San Francisco General Hospital to be treated for his injuries, which are not life-threatening.
No arrests have been made in connection with the shooting, but investigators believe the case is connected to another recent pellet gun shooting in the city, police spokesman Sgt. Daryl Fong said.
In that case, the victim was asleep when someone fired two pellets through a window of the residence, police said.
The victim called police and when officers arrived, they were looking out the window when two more shots were fired. No one was struck by the shots.
Police searched the area but did not find the shooter, Fong said. Anyone with information about either shooting is encouraged to call the Police Department's anonymous tip line at (415) 575-4444 or send a tip by text message to TIP411.