An identifying code of a graph is a dominating set which uniquely determines all the vertices by their neighborhood within the code. Whereas graphs with large minimum degree have small domination number, this is not the case for the identifying code number (the size of a smallest identifying code), which indeed is not even a monotone parameter with respect to graph inclusion. We show that for every large enough Δ, every graph G on n vertices with maximum degree Δ and minimum degree δ≥clogΔ, for some constant c>0, contains a large spanning subgraph which admits an identifying code with size O(nlogΔδ). In particular, if δ=Θ(n), then G has a dense spanning subgraph with identifying code O(logn), namely, of asymptotically optimal size. The subgraph we build is created using a probabilistic approach, and we use an interplay of various random methods to analyze it. Moreover we show that the result is essentially best possible, both in terms of the number of deleted edges and the size of the identifying code.