An efficient and environmentally electrooxidative N-nitrosation of secondary amines using potassium/sodium nitrite as nitrosating agents has been developed. This strategy break through the innate combination of sodium nitrite and a strong acid. The reaction is compatible with the late-stage modification of pharmaceutical compounds and could be conducted in gram scale with high reaction efficiency.