Map from Google - Costa_Rica

The climate in Costa Rica is hot all year round in the plains and along the coasts, while it's milder in the plateau (in the so-called tierras templadas). In the Pacific coast and the plateau there's a dry season (from December to April), and a rainy season (May to November), in which rainfall is abundant, while in the eastern plain and coast the climate is equatorial, with abundant rainfall throughout the year.
Temperature variations are low, because the country is located near the Equator, so the main difference between the seasons is related to the rains. Anyway, most of the country is so rainy that it's covered by rainforests.

San José

The capital city of San José is located in the central part, at 1,100 metres (3,600 feet) above sea level, on a plateau (the Central Valley, between the Cordillera Central and the Cordillera de Talamanca), thus it has pleasant temperatures throughout the year, with cool nights and warm days. Here are the average temperatures.
Average temperatures - San José
San JoséJanFebMarAprMayJunJulAugSepOctNovDec
Min (°C)141415171717171616161614
Max (°C)242426262726252626252524
Min (°F)575759636363636161616157
Max (°F)757579798179777979777775

In San José there is little rain from December to March, and it almost never rains in January and February. The rainy season runs from May to November, and the wettest months are September and October, with around 300 millimetres (12 inches) per month. Here is the average precipitation.
Average precipitation - San José
San JoséJanFebMarAprMayJunJulAugSepOctNovDecYear
Prec. (mm)1552045230240210240310305145401805

The amount of sunshine is good in the dry season, but only mediocre in the rainy season, when the sky is often cloudy.
Sunshine - San José
San JoséJanFebMarAprMayJunJulAugSepOctNovDec
Sun (hours)788754444456

On the Pacific coast, the rainfall pattern is similar to that of San José and the plateau, although of course the temperature is higher. The Pacific coast is even slightly warmer than the Caribbean coast, especially in winter, when the north-east trade winds descend from the mountains and become hot and dry: the average daytime temperatures are around the 30/32 °C (86/90 °F) in the least hot period, from October to November, while they can reach 34/35 °C (93/95 °F) in March and April, before the rainy season.
The least rainy area of the country, where the savannah dominates, is the north-west (Province of Guanacaste), where the average rainfall drops to 1,300/1,500 mm (51/60 in) per year.
Here is the average precipitation in Puntarenas, located in the southern part of the Pacific Coast.
Average precipitation - Puntarenas
Prec. (mm)64530205215175225295280130301600

Here the heat is intense throughout the year, and from February to May is torrid in inland areas, with highs around 37 °C (99 °F), while on the coast it is a little less intense.
Average temperatures - Puntarenas
Min (°C)222223242424232323232322
Max (°C)343434353332323232323232
Min (°F)727273757575737373737372
Max (°F)939393959190909090909090

In Puntarenas too, the sun shines in the dry season, while in the rainy season the sky is often cloudy.
Sunshine - Puntarenas
Sun (hours)899865565568

The east coast and the plain overlooking the Caribbean Sea (see Puerto Limón) is rain-soaked, and it receives more than 3,000 mm (118 in) per year; here the climate can be defined as equatorial, that is, without a dry seasons. However, there are two peaks in the rains, in July and December, both with about 440 mm (17.5 in) of rain per month, and two relative minima in September-October and February-March, both with about 150/200 mm (6/8 in) per month. In this area, December is even the wettest month, and January is wetter than February and March. South of this coast, on the mountain slopes of the Braulio Carrillo National Park, precipitation reach 5,000 mm (195 in) per year!
Here is the average precipitation in Puerto Limón.
Average precipitation - Limón
Prec. (mm)3052301952703253004403151452153804503565

Along the coast of the Caribbean Sea, temperatures are a bit lower than on the Pacific coast, as the winds blow constantly from the sea, but for the same reason the humidity is higher. Here are the average temperatures of Puerto Limón.
Average temperatures - Limón
Min (°C)212121222323232222222221
Max (°C)292930303130303031303029
Min (°F)707070727373737272727270
Max (°F)848486868886868688868684

The sun on the east coast does not shine very often, as cloudy and rainy days are frequent all year round.
Sunshine - Limón
Sun (hours)556654455545

The sea in Costa Rica is warm all year round, as we can see in the following table, relative to the sea temperature at Quepos, which is on the Pacific coast (but on the coast of the Caribbean Sea, the sea temperature is similar).
Sea temperature - Quepos
Sea (°C)282829292929292928282828
Sea (°F)828284848484848482828282

At high altitude, above 2,000 meters, in the so-called tierras frìas, above 2,000 metres (6,600 feet), and even more on the slopes of the highest mountains and volcanoes, such as Cerro Chirripó, 3,820 metres (12,532 feet) high, or the volcano Irazú, 3,431 metres (11,257 feet), temperatures are low, especially in the winter months. Above 3,500 metres (11,500 ft), at night it can freeze throughout the year.

Costa Rica is almost always spared from hurricanes, whose path is usually located north of the country: in fact sometimes they can affect nearby Nicaragua; therefore the area most at risk is the northern one, which may be affected indirectly. The hurricane season runs from June to November (though they are most likely in October and November), during the rainy season, which in any case is generally not recommended for tourists.
The first hurricane to hit directly Costa Rica was Otto in November 2016, although Hurricane Nate, which formed on the sea to the east of the country in October 2017 and then moved north, has brought even more serious damage.
Then there are the depressions and tropical storms that can be formed on the Pacific, which are usually not intense, because they affect the country in the early stages of their formation, but can still bring heavy rains, which can cause landslides and floods.

When to go

The best time to visit Costa Rica, either for swimming or for exploring its rich environment, runs from January to mid-April, and in particular the months of February and March. It's hot in the lowlands, the sun shines and there's little rain, except on the east coast, which has we said is rainy throughout the year. The capital can be visited even in December.
To avoid the uncomfortable heat of spring, the province of Guanacaste can be visited in December and January.

What to pack

For San José and the tierras templadas: all year round, light clothing, a sweatshirt or sweater for the evening; raincoat or umbrella from May to November.
For plains and coasts: lightweight clothes; in the rainy season, a light sweatshirt and a light raincoat for thunderstorms.
For the high mountains: warm clothes, jacket, hiking boots.