Hervir vs. cocer

In Spanish, 'hervir' and 'cocer' both relate to the process of boiling, but they have nuanced differences in their usage.

Hervir

'Hervir' means to boil a liquid or bring it to its boiling point.
El agua empieza a hervir a los 100 grados Celsius.
(Water starts to boil at 100 degrees Celsius.)
Debes hervir el agua para hacer .
(You should boil the water to make tea.)
Voy a hervir la leche antes de agregar el chocolate.
(I am going to boil the milk before adding the chocolate.)

Cocer

'Cocer' means to cook food by boiling it in water or another liquid.
Voy a cocer las papas para la cena.
(I am going to boil the potatoes for dinner.)
Se necesita cocer el arroz durante 20 minutos.
(You need to cook the rice for 20 minutes.)
Para esta receta, debes cocer la pasta hasta que esté al dente.
(For this recipe, you need to cook the pasta until it is al dente.)

Summary

'Hervir' specifically refers to bringing a liquid to its boiling point. 'Cocer' generally refers to cooking food by boiling it in water or another liquid. While 'hervir' focuses on the temperature aspect of the process, 'cocer' emphasizes the cooking of ingredients.