We present the first lattice Nf=2+1+1 determination of the tensor form factor $f_T^{D pi(K)}(q^2)$ corresponding to the semileptonic and rare $D to pi(K)$ decays as a function of the squared 4-momentum transfer $q^2$. Together with our recent determination of the vector and scalar form factors we complete the set of hadronic matrix elements regulating the semileptonic and rare $D to pi(K)$ transitions within and beyond the Standard Model, when a non-zero tensor coupling is possible. Our analysis is based on the gauge configurations produced by ETMC with Nf=2+1+1 flavors of dynamical quarks, which include in the sea, besides two light mass-degenerate quarks, also the strange and charm quarks with masses close to their physical values. We simulated at three different values of the lattice spacing and with pion masses as small as 220 MeV. The matrix elements of the tensor current are determined for plenty of kinematical conditions in which parent and child mesons are either moving or at rest. As in the case of the vector and scalar form factors, Lorentz symmetry breaking due to hypercubic effects is clearly observed also in the data for the tensor form factor and included in the decomposition of the current matrix elements in terms of additional form factors. After the extrapolations to the physical pion mass and to the continuum and infinite volume limits we determine the tensor form factor in the whole kinematical region accessible in the experiments. A set of synthetic data points, representing our results for $f_T^{D pi(K)}(q^2)$ for several selected values of $q^2$, is provided and the corresponding covariance matrix is also available. At zero four-momentum transfer we get $f_T^{D pi}(0) = 0.506 (79)$ and $f_T^{D K}(0) = 0.687 (54)$, which correspond to $f_T^{D pi}(0)/f_+^{D pi}(0) = 0.827 (114)$ and $f_T^{D K}(0)/f_+^{D K}(0)= 0.898 (50)$.