In the Dungeons & Dragons (D&D) fantasy role-playing game, alignment is a categorization of the ethical and moral perspective of player characters, non-player characters, and creatures.

Most versions of the game feature a system in which players make two choices for characters. One is the character's views on "law" versus "chaos", the other on "good" versus "evil". The two , along with "neutral" in the middle, allow for nine alignments in combination. Later editions of D&D have shifted away from tying alignment to specific game mechanics; instead, alignment is used as a roleplaying guide and does not need to be rigidly adhered to by the player. According to Ian Livingstone, alignment is "often criticized as being arbitrary and unreal, but... it works if played well and provides a useful structural framework on which not only characters but governments and worlds can be moulded."

History D&D co-creator Gary Gygax credited the inspiration for the alignment system to the fantasy stories of Michael Moorcock and Poul Anderson.

The original version of D&D (1974) allowed players to choose among three alignments when creating a character: lawful, implying honor and respect for society's rules; chaotic, implying rebelliousness and individualism; and neutral, seeking a balance between the extremes.

In 1976, Gary Gygax published an article title "The Meaning of Law and Chaos in Dungeons and Dragons and Their Relationships to Good and Evil" in The Strategic Review Volume 2, issue 1, that introduced a second axis of good, implying altruism and respect for life, versus evil, implying selfishness and no respect for life. The 1977 release of the Dungeons & Dragons Basic Set incorporated this model. As with the law-versus-chaos axis, a neutral position exists between the extremes. Characters and creatures could be lawful and evil at the same time (such as a tyrant), or chaotic but good (such as Robin Hood).

Advanced Dungeons & Dragons (AD&D), released between 1977 and 1979, continued the two-axis system. The 1981 version of the Basic Set went back to the earlier one-axis alignment system.

AD&D 2nd Edition, released in 1988, retained the two-axis system. In that edition, a character who performs too many actions outside their alignment can find their alignment changed, and is penalized by losing experience points, making it harder to reach the next level.

D&D 3rd Edition, released in 2000, kept the same alignment system. However the Eberron Campaign Setting (2004), released for 3.5 Edition, subverted many of the established D&D tropes including alignment. Evil beings of traditionally good races and good beings of traditionally evil races were encouraged but the alignment definition remained true to D&D standards, with good and evil retaining their meanings. Oppositely aligned characters will side with each other briefly if a threat looms over all. Keith Baker highlighted that in Eberron "alignment is a spectrum".

D&D 4th Edition, released in 2008, reduced the number of alignments to five: lawful good, good, evil, chaotic evil, and unaligned. In that edition, "good" replaced neutral good and did not encompass chaotic good; "evil" replaced neutral evil and did not encompass lawful evil; "unaligned" replaced true neutral and did not encompass lawful neutral and chaotic neutral. 4th Edition was the start of de-emphasizing alignment in D&D. Wired highlighted that 4th Edition's de-emphasis of "alignment and traditional racial stereotypes", along with other adjustments to the core races, allowed for more "PCs and NPCs with unknown and shifting motives".

D&D 5th Edition, released in 2014, returned to the previous schema of nine alignments, and included a tenth option of "unaligned" for creatures that operate on instinct, not moral decision-making. With 5th Edition, alignment was decoupled from most of the D&D game mechanics, such as "no rules that limit certain classes to characters of a specific alignment, or spells that impact characters differently depending on" alignment. Players do not need to be rigid or "consistently faithful" to their alignment choice; alignment in this edition is more of a roleplaying guide. Starting with the publication of Icewind Dale: Rime of the Frostmaiden (2020) and Tasha's Cauldron of Everything (2020), player and monster races no longer had preassigned alignments. In December 2021, official errata removed the suggested alignments for playable races in 5th Edition sourcebooks. Mordenkainen Presents: Monsters of the Multiverse (2022), a sourcebook which revised roughly 250 previously published monsters, removed preassigned alignments for creatures except in the cases of specifically named characters. Creature stat blocks that also have playable races "now state that they can be any alignment" while "other monsters, such as demons, with a strong association to a given alignment feature the word 'typically' next to their alignment. This insinuates that exceptions to a preassigned alignment are possible, encouraging DMs to potentially subvert player expectations and utilize monsters in unanticipated ways".

Function Richard Bartle's Designing Virtual Worlds noted that alignment is a way for players to categorize their characters, along with gender, race, character class, and sometimes nationality. Alignment was designed to help define role-playing, a character's alignment being seen as their outlook on life. A player decides how a character should behave in assigning an alignment, and should then play the character in accordance with that alignment.

A character's alignment can change. If a lawful neutral character consistently performs good acts, when neutral or evil actions were possible, the character's alignment will shift to lawful good. During game sessions, the Dungeon Master decides when alignment violations occur, as it is subjective and often frowned upon, if not outright disallowed.

Characters acting as a party should have compatible alignments; a party with both good and evil characters may turn against itself. Bill Slavicsek and Richard Baker's Dungeon Master for Dummies noted that a party of good or neutral characters works better as the motivations for adventures are easier, the group dynamics are smoother, and the "heroic aspects of D&D shine through in ways that just don't happen when players play evil characters".

Axes

Law versus chaos The law versus chaos axis in D&D predates good versus evil in the game rules.

Originally the law/chaos axis was defined as the distinction between "the belief that everything should follow an order, and that obeying rules is the natural way of life", as opposed to "the belief that life is random, and that chance and luck rule the world". According to the early rulebook, lawful characters are driven to protect the interest of the group above the interest of the individual and would strive to be honest and to obey just and fair laws. Chaotic creatures and individuals embraced the individual above the group and viewed laws and honesty as unimportant. At that time, the rulebook specified that "chaotic behavior is usually the same as behavior that could be called 'evil. Neutral creatures and characters believe in the importance of both groups and individuals, and felt that law and chaos are both important. They believe in maintaining the balance between law and chaos and were often motivated by self-interest.

The third edition D&D rules define "law" and "chaos" as follows: Law implies honor, trustworthiness, obedience to authority, and reliability. On the downside, lawfulness can include closed-mindedness, reactionary adherence to tradition, judgmentalness, and a lack of adaptability. Those who consciously promote lawfulness say that only lawful behavior creates a society in which people can depend on each other and make the right decisions in full confidence that others will act as they should. Chaos implies freedom, adaptability, and flexibility. On the downside, chaos can include recklessness, resentment toward legitimate authority, arbitrary actions, and irresponsibility. Those who promote chaotic behavior say that only unfettered personal freedom allows people to express themselves fully and lets society benefit from the potential that its individuals have within them. Someone who is neutral with respect to law and chaos has a normal respect for authority and feels neither a compulsion to follow rules nor a compulsion to rebel. They are honest but can be tempted into lying or deceiving others if it suits them.

Good versus evil The conflict of good versus evil is a common motif in D&D and other fantasy fiction. Although player characters can adventure for personal gain rather than from altruistic motives, it is generally assumed that the player characters will be opposed to evil and will tend to fight evil creatures.

The third edition D&D rules define "good" and "evil" as follows:

Good implies altruism, respect for life, and a concern for the dignity of sentient beings. Good characters make personal sacrifices to help others. Evil implies harming, oppressing, and killing others. Some evil creatures simply have no compassion for others and kill without qualms if doing so is convenient or if it can be set up. Others actively pursue evil, killing for sport or out of duty to some malevolent deity or master. People who are neutral with respect to good and evil have compunctions against killing the innocent but lack the commitment to make sacrifices to protect or help others. Neutral people are committed to others by personal relationships.

Within the game, altruistic heroes and creatures such as angels are considered good. Villains and violent criminals are considered evil, as are inherently evil creatures such as demons and most undead. Animals are considered neutral even when they attack innocents, because they act on natural instinct and lack the intelligence to make moral decisions; in the fifth edition, this is expressed by labeling such beasts as "unaligned". According to Greg Littmann, the predetermined assignment of an alignment to monsters means that they are good or evil by nature. Nevertheless, the rules do allow for individual variances, permitting "a red dragon looking to defect to the side of good"—even though Littmann acknowledges the rarity of such situations. As 5th Edition developed, it removed preassigned alignments to races and monsters. While some monsters have a "strong association to a given alignment", nature is determined by the Dungeon Master.

Although good characters can be defined as having a respect for others, Littmann notes that this does not necessarily extend to the treatment of evil creatures—"a party of good characters will chop and char a tribe of orcs to so much smoking hamburger without the slightest hesitation or regrets".

Alignments The nine alignments can be shown in a grid, as follows: + Alignment Lawful Neutral Chaotic GoodLawful goodNeutral goodChaotic good NeutralLawful neutral(True) neutralChaotic neutral EvilLawful evilNeutral evilChaotic evil

The 3.5 edition Player's Handbook provided archetype examples of each alignment, as shown below.

Lawful good A lawful good character typically acts with compassion and always with honor and a sense of duty. However, lawful good characters will often regret taking any action they fear would violate their code, even if they recognize such action as being good. Such characters include gold dragons, righteous knights, paladins, and most dwarves.

Neutral good