If landing at the Juan Santamaria (San Jose) international airport (SJO) in “transit”, you can leave (exit) the airport, provided there is a minimum of 5 hours between your flights.
If your citizenship requires a visa to enter the country, you will be asked to provide it.
The maximum period of time you can stay as “transit” is twelve hours.
During this period, you are exempt from paying the departure tax, unless you are returning to the same country of origin. For example, if your flight is coming from Panama, and you stay in Costa Rica for eight hours, and then return to Panama, you will have to pay the departure tax.
Almost all airlines have the (depature) tax included now. Your airline will notify you (at the ticket counter) if that is not the case.