〜んです・〜の
(explaining, or asking for an explanation)
Plain form + んです (casual: の) · Noun / な-adjective + なんです
Sign up free to review this point on a spaced schedule.
んです after a plain form presents a sentence as an explanation or background, not a bare fact: すみません、頭が痛いんです, "sorry, (it's that) I have a headache", said when explaining why you're leaving early.
As a question it asks for an explanation: どうしたんですか, "what's wrong?"; 行かないんですか, "aren't you going? (how come?)".
Nouns and な-adjectives take な before it: 学生なんです, 暇なんです.
Between friends it's just の: どうしたの? 頭が痛いの.
It's one of the most used patterns in spoken Japanese. A bare 痛いです can sound oddly flat where a native speaker would say 痛いんです.
Register: んです in conversation, のです in writing, の between friends.
Examples
すみません、頭が痛いんです。
Sorry, I have a headache.
どうしたんですか。
What's wrong?
明日はテストがあるんです。
It's just that I have a test tomorrow.
実は、私、学生なんです。
Actually, I'm a student.
どこへ行くの?
Where are you off to?