In this paper I examine the genesis of Kant’s conception of a realm of ends, arguing that Kant first started to think of morality in terms of striving to be a member of a realm of ends, understood as an ideal community, in the early 1760s, and that he was influenced in this by his encounter with the Swedish mystic Emanuel Swedenborg. In 1766 Kant published Dreams of a Spirit Seer, a commentary on Swedenborg’s magnum opus, Heavenly Secrets. Most commentators take Kant’s attitude towards Swedenborg to have been entirely negative, and argue that, at the most, Kant’s encounter with him had a purely negative impact on Kant’s development, inducing him to reject certain of his early metaphysical positions. I argue, in contrast, that Swedenborg had a positive influence on Kant’s development, particularly on his ethics, for Kant’s conception of a realm of ends is modeled on Swedenborg’s conception of heaven as a community of spirits governed by moral laws. For the mature Kant, the idea of a realm of ends is an idea of pure reason, being the idea of an intelligible world, or community of autonomous beings. Central to this idea is the thought that there is some sort of real interaction between members of such a community. Until his engagement with Swedenborg, however, Kant had believed that interaction was only possible between embodied beings. I argue that Kant’s engagement with Swedenborg in the early 1760s convinced him that it is possible for us to conceive of interaction between spirits. Swedenborg’s descriptions of heaven as a community of spirits governed by moral laws, standing in non-spatial relationships to one another, provided Kant with a way of conceiving of a community of intelligible individuals. That Kant’s idea of a realm of ends is modeled on a particular conception of heaven should not be surprising if we remember that Kant often refers to the idea of a realm of ends as ‘the kingdom of Heaven’. Although we can trace the genesis of Kant’s idea of a realm of ends to Swedenborg’s account of heaven, by the 1780s Kant’s idea of such a realm had departed from Swedenborg’s conception in two major respects. Firstly although Swedenborg conceives of heaven as a kingdom governed by divine laws, he does not suggest that the members of the kingdom must be the ‘givers’ of these laws. The mature Kant, in contrast, will argue that the idea of a realm of ends is the idea of a community in which the members of the community are the givers of the laws that provide the community with its unity. In other words, the mature Kant believes that our idea of a realm of ends is the idea of a community of autonomous individuals. Secondly, Swedenborg conceives of heaven as a community of spirits governed by laws of love, or what Kant will call laws of benevolence. The mature Kant, however, will maintain that we must conceive of the realm of ends as a political