A diode is a semiconductor device allowing current to flow in one direction only, while a capacitor is a component that stores electrical energy in an electric field.