Solid acid catalysts are environmentally friendly alternatives to the use of mineral acids in a range of applications, including the esterification of carboxylic acids. Here, a phosphorus-and nitrogen-doped, carbon-modified, fully heterogeneous solid acid catalyst was prepared by pyrolysis of a mixture of melamine and tungstophosphoric acid at 250, 500, and 750 °C under a nitrogen atmosphere provided. The structure of the different catalysts was evaluated by surface area measurements, XRD, XPS, Raman spectroscopy, elemental analysis, and electron microscopies. Pyrolysis at 500 °C created complex solid materials with larger surface area and significantly higher acidity, which can be attributed to WO 3 formation on a heteroatomic (N,P)-carbon structure. The 500 °C-treated heterogeneous catalysts showed remarkably better activity for esterification of palmitic acid and were thus applied in the esterification of a broad range of carboxylic acids with good overall yields. Furthermore, the solid acid catalyst can be easily recovered and recycled up to eight times without significant loss of activity with no leaching of species to the reaction mixture.