We prove that the derived category of a Grothendieck abelian category has a unique dg enhancement. Under some additional assumptions, we show that the same result holds true for its subcategory of compact objects. As a consequence, we deduce that the unbounded derived category of quasi-coherent sheaves on an algebraic stack and the category of perfect complexes on a noetherian concentrated algebraic stack with quasi-finite affine diagonal and enough perfect coherent sheaves have a unique dg enhancement. In particular, the category of perfect complexes on a noetherian scheme with enough locally free sheaves has a unique dg enhancement.