Can You Pray on the Sidewalk When the Mosque Is Full?
Question

I know that Islam forbids praying on the sidewalk, but if the mosque is full and we need to pray on the sidewalk, is that valid?
Praise be to Allah.Is Praying on the Sidewalk Permissible in Islam?
Praying on the sidewalk is disliked according to the majority of jurists, because it is the part of the street where people walk.
Why Is Praying on Sidewalks Disliked?
The reason for it not being allowed to pray there is that it is a transgression against people’s rights, and blocks their way, and because the worshipper will be distracted by the people passing by, so his focus when praying will be reduced.
When Is Praying on the Sidewalk Allowed?
But if the Muslims need to pray on the sidewalk because the mosque is too small, and there is no other place where they can pray, then in that case there is nothing wrong with praying on the sidewalk. (See: Al-Mawsu`ah Al-Fiqhiyyah, 27/114; 38/367)
Shaykh Ibn `Uthaymin (may Allah have mercy on him) was asked:
If the mosque is too small, what is the ruling on praying in the marketplace and the area surrounding the mosque?
He replied:
“There is nothing wrong with that, if someone has no choice but to pray in the marketplace or in the open spaces around the mosque. There is nothing wrong with that; even those who say that prayer is not valid if offered in the street make an exception in the case of Jumu`ah prayer and `Eid prayer, if the mosque is full and the people spill out into the marketplaces. The correct view is that an exception is made to that whenever there is a need. So if the mosque is full, there is nothing wrong with the people praying in the marketplaces.” (End quote from Majmu` Fatawa wa Rasa’il Ibn `Uthaymin, 12/331)
For more details, please see the following answers:
Conditions of the Validity of Prayer
Places Where Prayer Is Not Allowed
Can You Pray in a Moving Car?
Can Muslims Pray in a Church?
And Allah knows best.