 Fifth Harmony cowrote the song, which was initially developed by Priscilla Renea, Simon Wilcox, Benny Blanco, Julia Michaels, Brian Garcia and Nolan Lambroza.In contrast to the tropical sound of the album, "All In My Head (Flex)" blends reggae and pop music with elements of trap music.Additional instrumentation on the song includes a plucky guitar, synths and industrialized percussion.