Spending the night at Madrid airport is not that traumatic, as several services are available 24 hours a day. While there are hotels nearby, not all passengers are willing to pay for one night when their flight leaves after midnight or early in the morning. While there are Air Rooms inside the airport, which are suites with a common living room to rest for some hours, these are payable. If you are tight on money, you better find another alternative. The most important thing is that the airport is open 24 hours a day.
Terminal 1 is not very comfortable nor does it have many seats, except for some coffee shops, while terminals 2, 3 and 4 have more space and benches, but not very comfortable. Some of these (especially in the boarding areas) do not have armrests, and those are ideal to rest on two or three of them. If you find two or three together and unoccupied, do not hesitate and grab them. By gate 17 of Terminal 4S you can find a few reclinable chairs. Take into account that none of the terminals have areas with too much privacy and the lights usually stay on, so you best have an eye mask. If you have to sleep on the floor, have a blanket, since the place is usually cold at night. The children's playgrounds provide spaces with a bit more comfort. Another option (by paying around €30.00) is to use one of the VIP rooms. Some of them are even available 24 hours a day: Iberia Velázquez, Neptuno, Cibeles.
In terminals 1 and 4 there are luggage storage offices open 24 hours a day, and therefore, if your flight leaves early in the morning, you can leave your bags and sleep without having to watch your belongings, and then get them back at check-in time. The Terminal 4 office is in the Arrivals Lobby and in Terminal 1 it is opposite baggage room 2.
There are options open 24 hours a day in terminals 1, 2 and 4. In turn, there are vending machines with drinks, sandwiches and snacks in all terminals.
Showers are available only inside the VIP areas and the Air Rooms.
Madrid airport has a free and unlimited service and several access points in different areas of the terminals. There are also plugs for electric devices and printers.
Other services available around the clock: ATMs, currency exchange bureaus, gas stations, children's play areas.