The Shulchan Aruch · Orach Chayim
אורח חיים רי״טOrach Chayim 219
Siman 219 of 697 in Orach Chayim — 10 se'ifim
הלכות שאר ברכותLaws of Other Blessings· siman 219
Se’if 1א׳
אַרְבָּעָה צְרִיכִים לְהוֹדוֹת. יוֹרְדֵי הַיָּם כְּשֶׁעָלוּ מִמֶּנָּה, וְהוֹלְכֵי מִדְבָּרוֹת כְּשֶׁיַּגִּיעוּ לַיִּשּׁוּב, וּמִי שֶׁהָיָה חוֹלֶה וְנִתְרַפֵּא, וּמִי שֶׁהָיָה חָבוּשׁ בְּבֵית הָאֲסוּרִים וְיָצָא, וְסִימָנָךְ: וְכָל הַחַיִּי"ם יוֹדוּךָ סֶלָּה. "חוֹלֶה "יִסוּרִים "יָם "מִדְבָּר.
The blessing of individual thanksgiving. 9 sections: Four people must give thanks: those who descend to the sea when they have come up from it; those who travel through deserts when they reach an inhabited area; one who was ill and recovered; and one who was imprisoned and was released. And your mnemonic is "and all the living shall thank You" — Choleh (sick), Yisurin (suffering/imprisonment), Yam (sea), Midbar (desert).
Se’if 2ב׳
וּמַה מְּבָרֵךְ: בָּרוּךְ אַתָּה ה' אמ "ה הַגּוֹמֵל לְחַיָּבִים טוֹבוֹת שֶׁגְמָלַנִי כָּל טוּב, וְהַשּׁוֹמְעִים אוֹמְרִים: מִי שֶׁגְּמָלְךָ כָּל טוּב הוּא יִגְמָלְךָ כָּל טוּב סֶלָּה.
What does he bless? "Blessed are You, Lord our God, King of the universe, who bestows goodness upon the undeserving, who has bestowed all goodness upon me." And those who hear respond: "May He who has bestowed all goodness upon you continue to bestow all goodness upon you forever."
Se’if 3ג׳
צָרִיךְ לְבָרֵךְ בְּרָכָה זוֹ בִּפְנֵי עֲשָׂרָה, וּתְרֵי מִינַיְיהוּ רַבָּנָן, דִּכְתִיב: וִירֹמְמוּהוּ בִּקְהַל עָם וּבְמוֹשַׁב זְקֵנִים יְהַלְּלוּהוּ (תְּהִלִּים קז, לב), וְאִם לֹא שְׁכִיחֵי רַבָּנָן, לֹא יַנִּיחַ מִלְּבָרֵךְ; וְנָהֲגוּ לְבָרֵךְ אַחַר קְרִיאַת הַתּוֹרָה, לְפִי שֶׁיֵּשׁ שָׁם עֲשָׂרָה; וְאִם בֵּרַךְ בְּפָחוֹת מֵעֲשָׂרָה, יֵשׁ אוֹמְרִים שֶׁיָּצָא, וְיֵשׁ אוֹמְרִים שֶׁלֹּא יָצָא, וְטוֹב לַחֲזֹר וּלְבָרֵךְ בִּפְנֵי עֲשָׂרָה בְּלֹא הַזְכָּרַת שֵׁם וּמַלְכוּת.
One must recite this blessing before ten people, two of whom should be Torah scholars, as it is written "let them exalt Him in the congregation of the people and praise Him in the assembly of elders." If Torah scholars are not available he should not refrain from blessing. The custom is to bless after the Torah reading since ten are present. If he blessed before fewer than ten, some say he has fulfilled his obligation and some say he has not — it is best to bless again before ten without mentioning God's name and kingship.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0