The invention relates to a preparation method of two-dimensional transition metal carbide or nitride. The preparation method comprises the following steps: uniformly mixing metal carbide or metal nitride with strong alkali to obtain a mixture, wherein the metal carbide or the metal nitride is selected from at least one in the group consisting of Ti2AlC, Ti3AlC2, Ti3SiC2, Ti4SiC3, Ti2AlN, V2AlC, V3AlC2, V4AlC3, V4SiC3, Nb2AlC, Nb4AlC3, Nb4SiC3, Ta2AlC, Ta3AlC2 and Ta3SiC2; the strong alkali is selected from at least one in the group consisting of KOH, RbOH and CsOH; washing the mixture by use of deionized water to obtain a single-layer dispersed two-dimensional transition metal carbide or nitride colloidal solution. The preparation method disclosed by the invention is an environmental-friendly and pollution-free method for obtaining a single-layer two-dimensional nanometer lamella.