The explosion was reported at about 1:25 p.m. in a blue U.S. Postal Service collection box at the corner of 24th Avenue and Clement Street, police Sgt. Mike Andraychak said.
The department's bomb squad responded and police blocked off Clement Street between 22nd Avenue and 25th Avenue, and 24th Avenue from Geary Boulevard to California Street, Andraychak said.
The exterior of the mailbox was not damaged, which suggested the explosive device was relatively small, he said.
Investigators determined that a firework had been lit and tossed into the mailbox, Andraychak said.
He said no evacuations were needed, and that San Francisco Municipal Railway service was not affected.
No injuries were reported.
San Francisco police and postal service police are continuing to investigate the explosion, Andraychak said.
The scene was cleared at about 2:25 p.m.