AbstractQuantum network coding (QNC) aims at alleviating quantum communication congestion in quantum networks. Although several QNC protocols have been presented, they cannot meet the practical requirements that part of source nodes intend to transmit their quantum states with same or different qubit numbers via the bottleneck network simultaneously. Here, the study presents a flexible QNC protocol by using quantum multiplexing. First, the entangled pairs are generated between adjacent nodes in a heralded way by using quantum multiplexing. Then the quantum memories of the source nodes and the ones of the corresponding target nodes are entangled when the intermediate nodes execute multiple rounds of entanglement swapping operations on their quantum memories. Finally, the quantum states are transmitted from the source nodes to their corresponding target nodes by means of quantum teleportation. Compared with the existing protocols, the protocol allows an arbitrary part of the source nodes to transmit their quantum states with same or different qubit numbers via the bottleneck network simultaneously, thereby exhibiting its flexibility.