A sandbox is a container on most locomotives, multiple units and trams that holds sand, which is dropped on the rail in front of the driving wheels in wet and slippery conditions and on steep grades in order to improve traction.
The sand may be delivered by gravity, by a steam-blast (steam locomotives) or by compressed air. Gravity sanding requires that the sand be dry so that it runs freely. Locomotives used multiple sandboxes, so that their delivery pipes could be short and near-vertical. Engine sheds in the UK were equipped with sand drying stoves, so that sandboxes could be refilled each morning with dry sand. Steam locomotives in the USA had a single sandbox, called a sand dome on top of the boiler where the rising heat helped to dry the sand. Even with this arrangement, sand pipes tended to clog, and by the 1880s, pneumatic sanding systems were being proposed.
The development of steam sanding was influential on locomotive design. As the sand could now be blown horizontally and directly under the wheels, it was no longer blown away by cross-winds before it could be effective. This prompted a resurgence of interest in some older single-driver locomotive designs, that had previously been limited by their adhesion performance. The development of Holt's steam sanding gear on the Midland Railway in 1886 prompted Johnson to design his successful 'Spinners' of 1887, twenty-one years after the last singles, and which would remain in production for a further sixteen years.
On diesel and electric locomotives and railcars, sandboxes were and are fitted close to the wheels so as to achieve the shortest possible length of delivery pipe. Depots may have a sand drier installed to warm and to dry the sand before it is used.