In a restaurant:
- If they have a bathroom, must they let paying or unpaying customers use it?
- Can they deny use to people who have not bought anything?
- There's a McDonald's that does not allow use of its bathroom after 11pm. Is this legal?
In a restaurant:
Like the others asked, you need make clear where in the world you are talking about.
My brother owns a bar in London England - My understanding is if you have seats for five or more people, then you must have washrooms during business opening hours.
If the business is closed, or if you are not a customer, they do not have to let you in the premises, let alone let you use their washroom.
Some premises ask non-customers to pay - they can - They are in a service industry, and keeps the facilities clean and/or functional.