Quick answer
Мои́ соболе́знования.
maí sabaléznavaniya — and the shorter, warmer things people actually say
The options
The formal phrase
Мои́ соболе́знования is the safe, correct thing to say or write to anyone, at any distance. For a card or a message, Прими́те мои́ и́скренние соболе́знования — please accept my sincere condolences.
What people say to friends
Among people who are close, the formal phrase can feel stiff. Крепи́сь (be strong), Я ря́дом (I’m here), Держи́сь (hold on) and a simple Я зна́ю. Мне о́чень жаль. do more. Practical offers matter more than words.
What to avoid
Do not say Всё бу́дет хорошо́ — it rings hollow here. Avoid asking how the person died unless they bring it up. And поздравля́ю obviously never belongs anywhere near this; it is a congratulation.
What you hear back
Typical mistakes
Мои́ соболе́знование.
Мои́ соболе́знования.
The phrase is plural.
Всё бу́дет хорошо́.
Мне о́чень жаль.
Reassurance of that kind is out of place at a death.
Check yourself
Which is the safe formal phrase?