Bereshit / Genesis 38:26
וַיַּכֵּר יְהוּדָה וַיֹּאמֶר צָדְקָה מִמֶּנִּי כִּי־עַל־כֵּן לֹא־נְתַתִּיהָ לְשֵׁלָה בְנִי וְלֹא־יָסַף עוֹד לְדַעְתָּה׃
Yehudah recognised [them] and said: "She is right, it is from me. For I did not give her to my son Shelah." And he was not intimate with her again.
Pshat פְּשָׁט
"She is right"
Rashi: "right" in her words, "from me" she is pregnant. And the sages teach: a voice from heaven said "from Me": by My design kings will come from her. Ramban: "more righteous than I", as Shaul (Saul) said to David "you are more righteous than I". She acted by the law: Shelah should have married her, and if not, Yehudah himself as the nearest kinsman.
How Rashi and Ramban explain it
Remez רֶמֶז
A confession that opens the way for others
Da'at Zekenim: a human court executes one who confesses, but God has mercy on one who confesses and forsakes his sin. Seeing Yehudah (Judah) confess, Reuven (Reuben) confessed his sin. So in the blessing of Moshe (Moses) Reuven and Yehudah stand one after the other, although by age Shimon (Simeon) and Levi come between them. Sforno: Tamar acted by deceit, but for an aim pleasing to God. "Greater is a sin for the sake of Heaven than a mitzvah not for its sake."
How Da'at Zekenim and Sforno explain it
Drash דְּרָשׁ
Three voices from heaven
In Tanchuma, Rabbi Yehudah HaLevi bar Shalom teaches: when Tamar was being led out to be burned, she could not find the things Yehudah had left as a pledge. God opened her eyes, she found them and sent word: "Yehudah (Judah), recognise your Creator." Because Yehudah saved three souls from fire, Tamar and the twins, and one from the pit, Yosef (Joseph), God saved his descendants: Chananyah (Hananiah), Mishael and Azaryah (Azariah) from the furnace and Daniel from the lions' den. Bereshit Rabbah: the holy spirit appeared in three courts: of Shem, of Shmuel (Samuel) and of Shlomo (Solomon).
How Midrash Tanchuma (Buber) and Bereshit Rabbah explain it
Sod סוֹד
The hidden witness
Rabbeinu Bahya: when the seal, sash and staff were brought, Yehudah (Judah) confessed at once. By Ramban, she is more righteous, since she meant to fulfil the mitzvah of marrying a brother's widow. And the midrash says: a voice from heaven said "from Me". Rabbi Elazar teaches: in three places the holy spirit appeared, in the courts of Shem, Shmuel (Samuel) and Shlomo (Solomon). Yehudah said "right", and the holy spirit said "from Me".
How Rabbeinu Bahya explain it