"The Heart Wants What It Wants" was written by Selena Gomez, Antonina Armato, David Jost, and Tim James. It is a midtempo pop and R&B song, that contains a minimal electropop beat complete with finger snaps, ominous synths and haunting groans. Several critics noted the reminiscence of the song to the works by singers Lorde and Lana Del Rey.
