There are no details as to what he was doing in the water, but the boy was at the beach as part of a school trip.
Firefighters were called to the beach on San Francisco's northern waterfront around 1:30 p.m. Friday. Witnesses say a Coast Guard helicopter helped coordinate the rescue effort, which took place about 300 yards offshore. Witnesses also say the boy looked very cold and tired when he was brought to shore.
The 12-year-old was transported to California Pacific Medical Center for treatment.
The boy was not seriously injured. He had been at the beach for a school trip.
A U.S. Coast Guard helicopter assisted in the rescue, the dispatcher said.
Bay City News contributed to this report.