State conversion between Greenberger-Horne-Zeilinger (GHZ) state and W state is an open challenging problem because they cannot be converted to each other only by local operations and classical communication. Here we propose a cavity quantum electrodynamics method based on interference of polarized photons emitted by the atoms trapped in spatially separated optical cavities that can convert a three-atom W state to a GHZ state. We calculate the success probability and fidelity of the converted GHZ state when the cavity decay, atomic spontaneous decay, and photon leakage of the cavities are taken into account for a practical system, which shows that the proposed scheme is feasible and within the reach of current experimental technology.