The Shulchan Aruch · Orach Chayim
אורח חיים רפ״זOrach Chayim 287
Siman 287 of 697 in Orach Chayim — 1 se'if
הלכות שבתLaws of Shabbat· siman 287
Se’if 1א׳
יְכוֹלִים לְנַחֵם אֲבֵלִים בְּשַׁבָּת, וְכֵן יְכוֹלִים לְבַקֵּר אֶת הַחוֹלֶה. וְלֹא יֹאמַר לוֹ כַּדֶּרֶךְ שֶׁאוֹמֵר לוֹ בַּחֹל, אֶלָּא אוֹמֵר לוֹ: שַׁבָּת הִיא מִלִּזְעֹק וּרְפוּאָה קְרוֹבָה לָבֹא, וְרַחֲמָיו מְרֻבִּים וְשִׁבְתּוֹ בְּשָׁלוֹם. הַגָּה: וְיֵשׁ אוֹמְרִים דְּאֵין צָרִיךְ לוֹמַר וְרַחֲמָיו מְרֻבִּים, וְכֵן נָהֲגוּ (רַמְבַּ"ם פֶּרֶק כ"ד).
Comforting Mourners and Visiting the Sick on Shabbos: We may comfort mourners on Shabbat and we may visit the sick. We do not speak to them the same way we speak to them during the week. Rather, we say to them “It is Shabbos, when it is forbidden to cry out; healing will [surely] come soon, for His mercies are abundant; rest on Shabbos in tranquility". Rema: There are those who say that we do not have to say 'His mercies are abundant' and such is the custom. (Rambam)
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0