also: なーんだ · なあんだ
interjection
what!; oh!
Expresses surprise, realization, or mild disappointment. Often drawn out as なーんだ or なあんだ.
なんだ、もう終わったのか。
Oh, it's already over?
なーんだ、そんなことか。
Oh, is that all it was?
interjection
what the heck; what the; damn
Only with reading なんだ
Stronger exclamation of annoyance, disbelief, or frustration. Restricted to the reading なんだ.
なんだ、このやろう!
What the hell, you jerk!
なんだよ、急に呼び出して。
What the heck, calling me out so suddenly.
なに is the standard question word 'what', while なんだ is an interjection expressing surprise or annoyance.
Contraction of 何 (なに, 'what') + だ (copula). The interjection use developed from rhetorical questions.