Answer by Professional Japanese Teacher
The word “nani” means “what”. It usually appears as part of a question, for example, “なにを食(た)べますか Nani o tabemasu ka” (What are you going to eat?).
We usually see anime characters exclaiming “Nani??” in fighting scenes in the anime. The characters use “nani” to express surprise, frustration, shock, disbelief, dismay, or anger at their current situation. For example, they may say “なに？もう一度(いちど)言(い)ってみろ！ Nani? Mooichido ittemiro!” (What? Try saying that again!)
Therefore, if you were to use the word “nani” as a direct equivalent to “what”, it may sound rude to the listener. In this case, if you wish to ask, “What is it?”, you can use “なんですか。Nan desu ka?” to be polite.
For more interrogative expressions such as “what is it” or “where is it”, check out our following article!
Top 10 Japanese Interrogative Expressions