Then a (big) fish swallowed him as he had done an act worthy of blame.
Then Allah commanded a large fish from the Green Sea (i.e., Mediterranean Sea) to cleave the oceans and come and swallow Yunus, peace be upon him, without cutting his flesh or breaking his bones. The fish came and Yunus, peace be upon him, threw himself overboard, and the fish swallowed him and took him away, traveling through all the seas with him. When Yunus had stayed for some time in the fish's belly, he thought that he had died; then he moved his head and legs and arms, and saw that he was alive. He prayed in the belly of the fish, and one of the things he said in his main prayer was;
"O Lord, I have taken as a place of worship to You a place which no other person has reached."
They differed as to how long he spent in the belly of the fish.
Some said three days; this was the view of Qatadah.
Some said seven days; this was the view of Ja`far As-Sadiq, may Allah be pleased with him.
Some said forty days; this was the view of Abu Malik.
Mujahid said, narrating from Ash-Sha`bi, "It swallowed him in the morning and cast him forth in the evening."
And Allah knows best how long exactly was.
Allah says,
فَلَوْلَا أَنَّهُ كَانَ مِنْ الْمُسَبِّحِينَ