The notion of extriangulated category was introduced by Nakaoka and Palu giving a simultaneous generalization of exact categories and triangulated categories. Our first aim is to provide an extension to extriangulated categories of Auslander's formula: for some extriangulated category $\mathcal{C}$, there exists a localization sequence $\operatorname{def}\mathcal{C} \to \mod\mathcal{C} \to \operatorname{lex}\mathcal{C}$, where $\operatorname{lex}\mathcal{C}$ denotes the full subcategory of finitely presented left exact functors and $\operatorname{def}\mathcal{C}$ the full subcategory of Auslander's defects. Moreover we provide a connection between the above localization sequence and the Gabriel–Quillen embedding theorem. As an application, we show that the general heart construction of a cotorsion pair $(\mathcal{U}, \mathcal{V})$ in a triangulated category, which was provided by Abe and Nakaoka, is the same as the construction of a localization sequence $\operatorname{def}\mathcal{U} \to \mod\mathcal{U} \to \operatorname{lex}\mathcal{U}$.