The incident happened at an apartment building near Bear Valley Road and Cypress Avenue shortly after 3p.m., according to officials from the San Bernardino County Fire Department.
Fire crews lowered some ropes to the boy, who was conscious and talking, officials said. They had him slip the ropes on and they pulled him out.
The child was taken to a nearby hospital with minor injuries.
Officials said the sinkhole was about 15 feet deep and had liquid at the bottom.
City crews were expected to arrive to the scene to assess the hole.