Hans Christian Andersen’s tale about a swineherd who disguises himself to test a princess is The Swineherd.
The story follows a prince whose genuine gifts are rejected by an emperor’s daughter. The prince then disguises himself as a swineherd and creates clever objects that attract the princess’s attention. His experiment reveals that she values novelty and spectacle more readily than sincere affection or artistic gifts.
Andersen published the tale in 1841. Its satire is directed at vanity, shallow desire, and the misuse of royal privilege. The story ends with the princess losing the relationship she might have had with the prince, rather than receiving the happy ending found in many courtship tales.
The Swineherd is often confused with The Princess and the Pea because both involve a princess and a test of character. Their plots are different: the earlier tale concerns a hidden pea beneath mattresses, while The Swineherd uses disguise and mechanical inventions.