We introduce the concept of optimal subcategory (an abstract form of completeness) and use it to develop a categorical version of the Stone-Weierstrass theorem.