When a spell with X in its mana cost is on the stack, X is equal to the value chosen by the caster. The mana value of the spell on the stack is calculated using that chosen value, not zero. This is governed by CR 202.3b.
However, X is treated as 0 for mana value purposes everywhere except the stack — for example, when the card is in your hand, graveyard, exile, or on the battlefield (unless it's a permanent where X was defined as it entered). This distinction is important for effects that check mana value in those zones.
So if you cast Fireball with X = 5 and pay 6 mana total (5 for X plus 1 for the generic/red cost), while Fireball is on the stack its mana value is 6, not 1. An effect like Spell Snare (counters a spell with mana value 2) would not be able to counter it.
Conversely, if someone asks what Fireball's mana value is while it sits in your graveyard, X = 0, making its mana value 1. This matters for cards like Snapcaster Mage or graveyard-based cost-reduction effects.
Key rule references: CR 202.3b states X = 0 in all zones except the stack, and CR 202.3c clarifies that on the stack X equals the chosen value for purposes of calculating mana value.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.