My personal experience - not a native speaker, studied Iranian Persian formally for 4 years, and spent 2 months studying in Tajikistan while I was at a relatively low level.
The formal registers are very close, and it's mainly the vowels that differ. What's interesting is that Tajik (and I think Dari/Afghan Persian as well) retains a long i vs long e vowel difference that have merged in Iranian Persian. So in Persian, shir
means both lion and milk. In Tajik, sher
is lion and shir
A lot of everyday words in Tajik are different from Iranian Persian. Sometimes these are words that sound old-fashioned/literary in Persian but still used in Tajik, and a native speaker would be able to figure it out - khurok/khoraak for food, kalon/kalaan for big, hechgoh/hichgaah for never. Others come from Uzbek or Russian or other places.
It was a big shock for me visiting Tajikistan with the purpose of studying Persian, and find the people around me had a different word for hello, goodbye, thank you, food, family, big, small... nearly every common word was different, unless they specifically tried to speak 'adabi' with me. But I caught on quickly
People from both countries can appreciate the classic poetry of Ferdowsi, Rudaki, Moulana etc, and an Iranian and a Tajik should have no problem communicating if they speak a little formally. But I think if you dropped someone from Tehran into the zaboni kucha
of Dushanbe, they would have some trouble at first!