For the first time, a search for the rare decay of the W boson to three charged pions has been performed. Proton-proton collision data recorded by the CMS experiment at a center-of-mass energy of 13 TeV, corresponding to an integrated luminosity of 77.3 fb-1, have been analyzed. No significant excess is observed above the background expectation. An upper limit of 1.01×10-6 is set at 95% confidence level on the branching fraction of the W boson to three charged pions. This provides a strong motivation for theoretical calculations of this branching fraction.