The process in which a relatively unspecialized cell acquires the specialized features of a foam cell. A foam cell is a type of cell containing lipids in small vacuoles and typically seen in atherosclerotic lesions, as well as other conditions.