Bradley Sweetman, 19, and Paul Keegan, 17, spat at their victim and punched him as he stood alone at a London underground station, Southwark Crown Court, south London, was told.
Sentencing Sweetman to six months youth custody and Keegan to four months, Judge Michael Harris said: 'What you said at the time makes it quite clear that you attacked that boy for no other reason than that the colour of his skin was different from yours.
'It is positively barbaric when a person is attacked by another because they don't like the colour of their skin . . . '
The court was told that Keegan, 16 at the time, and Sweetman, 18, picked on Omar Sharif, 18, as he was waiting for a train at Aldgate East station, in the East End of London.
Both punched Mr Sharif but were prevented from continuing by an off-duty policeman.
Sweetman, of West Ham, east London, and Keegan, of East Ham, east London, were cleared by a jury last month of robbing Mr Sharif of pounds 3.
Both pleaded guilty to causing actual bodily harm, but denied their assault was a racist attack, claiming they had had too much to drink.