Pastilla vs. píldora vs. comprimido vs. tableta

The Spanish words 'pastilla', 'píldora', 'comprimido', and 'tableta' all generally refer to a small, solid piece of medication that can be swallowed. While often used interchangeably in everyday language, they can imply slight differences in form and usage.

Pastilla

'Pastilla' is a general term that can be used to refer to any pill or tablet. However, it is often used to describe lozenges or other pills intended to dissolve or be chewed in the mouth.
Tomé una pastilla para el dolor de cabeza.
(I took a pill for the headache.)
Esta pastilla se disuelve en la boca.
(This pill dissolves in the mouth.)

Píldora

'Píldora' specifically refers to a small, coated pill that is swallowed and often contains medication. It's also commonly used for contraception 'the pill'.
La doctora me recetó unas píldoras para la presión arterial.
(The doctor prescribed some pills for blood pressure.)
Toma la píldora anticonceptiva todos los días.
(She takes the contraceptive pill every day.)

Comprimido

'Comprimido' is a term often used to describe tablets that have been compressed under high pressure, typically round or oval in shape.
Mi médico me dio un comprimido para la migraña.
(My doctor gave me a tablet for the migraine.)
Estos comprimidos son muy eficaces para tratar la fiebre.
(These tablets are very effective for treating fever.)

Tableta

While 'tableta' can technically refer to a medicinal tablet, it is more often used in reference to a slab or block of something, such as chocolate or clay. In terms of medication, it might imply something larger than a typical pill.
Compré una tableta de chocolate amargo.
(I bought a bar of dark chocolate.)
Esta tableta de medicamento es muy grande y difícil de tragar.
(This tablet of medicine is very large and hard to swallow.)

Summary

'Pastilla', 'píldora', 'comprimido', and 'tableta' are all Spanish terms used to refer to different types of pills or tablets. While they are often interchangeable, each term can suggest particular characteristics or uses of the medication, from its size and form (compressed or dissolvable) to its function (such as contraceptive pills).