Listings state the mattress size they take, the interior rail dimensions, the slat spacing and the weight capacity. Slat spacing above three inches is too wide for a foam mattress without a solid base panel underneath.
Measure the room with the bed in place plus 24 inches of walkway on the sides you use. For bunk beds, the top rail height and the ladder position decide whether the room works.