Roll to defend codes are shorthand systems used in tabletop role-playing games (TTRPGs) to determine whether a character successfully blocks, dodges, or parries an incoming attack. You enter the character’s relevant defense bonus and the attacker’s roll result, and the calculator tells you the minimum die roll needed to avoid the hit. This page explains how these codes work, how to read them, and how to build your own.
Formula
The core mechanic is simple: you need to roll a d20 (a 20-sided die) and get a result that, when added to your defense bonus, equals or exceeds the attacker’s roll. The formula is:
Minimum roll needed = Attack roll − Defense bonus
Where:
- Attack roll is the total the attacker achieved (including their own bonuses).
- Defense bonus is your character’s total modifier for the defense type being used (Armor Class, Dodge, Parry, etc.).
- Minimum roll needed is the lowest number you must roll on a d20 to succeed. If this number is 1 or less, you succeed automatically (unless a natural 1 is a critical failure). If it is 21 or more, you cannot succeed (unless a natural 20 is a critical success).
The chance of success is calculated as (21 − minimum roll needed) × 5%, because each face of a d20 has a 5% probability.
Worked Example
Using the default values: your defense bonus is +5, and the attacker’s roll is 15.
- Minimum roll needed = 15 − 5 = 10.
- You need to roll a 10 or higher on a d20.
- The number of successful outcomes is 21 − 10 = 11 (rolls 10 through 20).
- Chance of success = 11 × 5% = 55%.
So with a +5 bonus against an attack roll of 15, you have a 55% chance to defend successfully.
Background: Where Did “Roll to Defend” Come From?
The phrase “roll to defend” became popular in the 2000s with the rise of d20-based games like Dungeons & Dragons 3rd Edition, where attacks were resolved with an active d20 roll against a static Armor Class. Some systems, such as Pathfinder and Starfinder, later introduced optional rules for active defense, where the defender rolls instead of the attacker. In these variants, the “defense code” is a shorthand notation like D20+5 or Parry 12, telling the player what to add to their roll and what target number to beat.
In video games and online communities, “roll to defend” is also used as a humorous meme phrase, often in chat-based RPGs, to announce that a character is attempting to block an attack. The actual mechanics vary, but the underlying math is the same everywhere: compare a random roll plus a modifier against a target number.
How to Read a Defense Code
A defense code typically appears in a character sheet or monster stat block. Common formats include:
- AC 15 (Armor Class) – the number an attacker must meet or beat.
- Dodge +7 – add 7 to your d20 roll, then compare to the attack total.
- Parry 12 – a flat target number for the defender’s roll.
- DC 14 (Difficulty Class) – often used for saving throws, which are a form of defense against spells or traps.
In all cases, the core question is: What do I need to roll to succeed? The calculator above answers that directly.
Choosing the Right Defense Type
Different defenses apply to different situations. A character might have several options, and the game master (GM) decides which one applies. Common defense types include:
- Armor Class (AC) – the default against physical attacks; includes armor, shield, and Dexterity bonuses.
- Dodge – used when you rely on mobility to avoid an attack; often a separate bonus from AC.
- Parry – used when you actively block with a weapon; requires a free hand or a weapon in hand.
- Fortitude/Reflex/Will – saving throws against poison, area effects, and mental attacks, respectively.
When a player says “I roll to defend,” they should specify which defense they are using, because the bonus can differ. For example, a heavily armored knight might have AC 20 but a Dodge bonus of only +2, while a rogue might have AC 15 but Dodge +8.
Common Mistakes and Misconceptions
One frequent error is confusing the attack roll with the attack bonus. The attack roll is the final number after rolling a d20 and adding the attacker’s bonus. The attack bonus is just the modifier. In the formula, you need the total attack roll, not the bonus alone.
Another mistake is forgetting that a natural 20 on a defense roll is usually an automatic success, and a natural 1 is an automatic failure, regardless of modifiers. This means that even if the minimum needed is 21 or higher, you still have a 5% chance to succeed on a natural 20. Similarly, if the minimum needed is 1 or lower, a natural 1 still fails. The calculator above does not account for these critical rules, so adjust your expectations accordingly.
Finally, some players mistakenly add the defense bonus to the attack roll instead of subtracting it from the target. The formula is always: your roll + your bonus ≥ attack roll. Rearranged, that gives your roll ≥ attack roll − your bonus.
Alternatives to a Single Defense Roll
Some systems use different mechanics that achieve a similar result:
- Static Defense – the defender does not roll at all; the attacker rolls against a fixed number (e.g., AC 15). This is the most common in D&D 5e.
- Opposed Rolls – both sides roll and add modifiers; the higher total wins. Ties usually go to the defender.
- Damage Reduction – instead of avoiding the attack, the defender reduces the damage taken by a fixed amount or a roll.
- Armor as Damage Reduction – armor does not make you harder to hit, but it absorbs damage when you are hit.
Each method has trade-offs. Active defense adds excitement and player agency but slows down combat. Static defense is faster but can feel passive. The “roll to defend” code is just one tool in a game master’s toolkit.
Safety and Fairness in Homebrew Rules
If you are designing your own defense code, keep these guidelines in mind:
- Ensure the numbers are balanced: a defense bonus that is too high makes the character unhittable; too low makes them fragile.
- Test the math: a typical attack bonus should give the attacker a 50–70% chance to hit, which means the defender’s minimum needed roll should be in the 7–11 range.
- Be consistent: if you use critical successes and failures, apply them to both attacks and defenses.
- Communicate clearly: write the defense code in a way that the player immediately understands what to roll and what to add.
There is no official standard for “roll to defend” codes across all games, so always confirm with your game master or rulebook before relying on a particular format.
Frequently Asked Questions
What does “roll to defend” mean exactly?
It means the defender makes a d20 roll (plus their defense bonus) to avoid an attack, instead of the attacker rolling against a static number. The result must meet or beat the attack roll to succeed.
Do I add my defense bonus to the attack roll or subtract it?
You subtract it from the attack roll to find the minimum number you need to roll. Equivalently, you add it to your own roll and compare the total to the attack roll.
What is a good defense bonus?
It depends on the game’s power level. In D&D 5e, a typical character has an AC of 15–18, which corresponds to a defense bonus of +5 to +8 if using active defense. A bonus above +10 is very high and may be unbalanced.
Can I use this calculator for saving throws?
Yes. A saving throw is a defense roll against a spell or effect. Replace the attack roll with the spell’s save DC, and use your saving throw bonus as the defense bonus.
What if the minimum roll needed is 0 or negative?
That means you succeed automatically (unless a natural 1 is a critical failure). The calculator will show a negative number, but you should treat it as “no roll needed.”
Does a natural 20 always succeed on defense?
In most games, yes, a natural 20 is an automatic success on any d20 roll, including defense. A natural 1 is typically an automatic failure. Check your specific rulebook for confirmation.
Related
Formula used
in def | Defense bonus | - | 5 | -20 | 20 in atk | Attack roll result | - | 15 | 1 | 100 out need | Minimum d20 roll to defend | - | atk - def | 0 out chance | Chance to defend (%) | - | (21 - (atk - def)) * 5 | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Best Family Western Movies to Stream Right Now
- Luxury V6 Sports Sedan: Can It Easily Top 100k Miles?
- Puppets in TV Shows: Classic Proof They’re Better
- Best Streaming Remote: Top Picks for Every Setup
- Claude Pro Hidden Features Power Users Try
- Tesla Rental Prices: Why They’re So Low255.00 USD