Children have a reputation for selfishness. Picture a traditional morning-after-Halloween scene: A child is hunched over a huge mound of collected candy while their parent stands by begging them to share their spoils with a younger, less fortunate sibling. The frustrated parent in this scene embodies the common notion that the only way to get children to be fair is to forcibly extract it out of them, like blood from a stone.

After studying children’s fairness behavior for nearly a decade we argue that this reputation is, well, unfair.

We travel to public spaces in different cities and ask children to play a simple game: Two children who do not know each other are paired up and given an unfair distribution of candy. One child gets four candies, the other gets one candy. Here’s where things get interesting. One of the two children—the decider—can accept or reject the allocation. If the decider accepts, both children get their candy. If the decider rejects, both children get nothing. Imagine that, like the Halloween scenario, the child in power gets four and their partner gets one. What will they do?

If you are like most parents watching their children play our game, you probably think the decider will happily accept the four, creating a stark inequality with the peer. Children only focus on getting more for themselves, right? To the surprise and delight of many an unsuspecting parent, children—at least older children—frequently reject this unfair advantage. They are willing to sacrifice their own rewards to prevent someone else from getting the short end of the stick. Getting nothing seems better than getting more than a peer, even a child whom they have just met.

This act of self-sacrifice in the name of fairness is indeed surprising. But more than that, it flies in the face of our intuitions about where fairness comes from in our species. There is a commonly held belief that humans are fundamentally selfish agents and fairness is a construct designed to help us override our selfish instincts. Not only this, but the idea really seems to be that fairness doesn’t come naturally, which is why we need institutions like the justice system to make sure that fairness prevails. Psychologists and economists have begun to gradually chip away at this notion, showing that people are actually pretty fair even when they can get away with selfishness.

But this still doesn’t tell us where fairness comes from. Is fairness something that must be learned via extensive experience? Through explicit teaching from adults? To answer this question, we need to look to children. Indeed, a suite of recent studies with children suggests fairness is not something that takes a long time to develop or that must be enforced through formal principles and institutions of justice. Rather, fairness is an integral part of our developing understanding of how to social world operates and, perhaps more surprisingly, it guides children’s behavior from very early on.

Indeed, children apply a strong sense of fairness not only to themselves—they also stand up for others. We invited children to play a different game in which they learn about a decider who selfishly wanted to keep all candies for themselves, refusing to share with another peer. Our child participant then faces a choice: Do they stand by and do nothing or do they get involved and prevent the injustice? To make it especially difficult, children must pay a cost for intervening—they have to give up some of their own candy to prevent unfairness. Nevertheless, children regularly intervene, choosing to pay so they can prevent the selfish child from getting away with unfair behavior. Together, these findings show children hold themselves and others to high standards of fairness.

We are now sitting on a mountain of evidence from our studies as well as those conducted by others that suggests fair behavior has deep roots in development. Infants as young as 12 months expect resources to be divided equally between two characters in a scene. By preschool, children will protest getting less than peers, even paying to prevent the peer from getting more. As children get older, they are willing to punish those who have been unfair both when they are the victims of unfairness as well as when they witness someone else being treated unfairly. Older still, children show what we described above: They would rather receive nothing than receive more than a peer.

More recently, many developmental psychologists, including our team, have begun studying these behaviors across different cultures, asking whether children everywhere show a similar developmental pattern. What we have found is that certain aspects of fairness appear to be universal. For example, children everywhere seem to dislike getting less than a peer. Other forms of fairness, however, appear to be more culturally variable, perhaps shaped by local customs.

Of course, a mature sense of fairness consists of more than just reactions to inequality and, indeed, we see more sophisticated concepts of fairness in children as well. One bedrock of fairness is that you should share the spoils of your joint labor—equal work, equal pay. Children as young as three years are sensitive to this: When they have to work toward getting a toy or a treat, they are more likely to share the spoils equally with a peer co-worker than when each one worked on the task by themselves. They even track how hard each person worked and reward the one who worked more accordingly.

The bottom line here is that children, even young ones, show remarkable sophistication not just in their understanding of and conformity to norms of fairness but also in their ability to enforce fairness in others and to flexibly tune fairness to different situations. These exciting developments dovetail beautifully with work showing that adults are often fair even when they could be selfish, and suggest we need to overhaul the notion that humans are fundamentally out for themselves at the expense of others. Instead, we should adopt the idea that fairness is a key part of our developing minds from as early as they can be studied.

So, sure, children are selfish sometimes. We should recognize, however, that just like in adults, alongside their impetus for self-maximization runs a deep and maturing concern for fairness—not just for themselves but for others as well.