We have our 2015 iMac 27" on a built-in cabinet desk in the kitchen, which unfortunately means that if we accidentally trigger a GFI breaker it would shut the iMac down. We added an APC 650VA/350W UPS to protect the iMac, 8TB iTunes drive, and 6th Gen AirPort Extreme as an access point.
We have had a few brownouts, tripped breakers, or had <1 minute power outages and it has done well to keep the iMac from shutting down until we can reset the breaker or shut it down right away. This is probably the smallest I would consider using, and I HAD to use this small because nothing bigger would fit on the kitchen desk behind the iMac with the 8TB RAID-0 drive sitting under it. I didn't want to test how long it will last because I didn't want to mess up my HD if I let it shut down and the iMac is writing some random settings or iCloud sync at the time.
We also have a smaller APC 550VA UPS to protect the cable modem, 3TB Time Capsule, Drobo 5N NAS, and 8-port switch; and we have another APS 450VA UPS to protect our QNAP 4-drive media NAS and a couple of 5-port switches. Obviously too small to keep an iMac running, with maybe 220-250W of power.
My son is using a CyperPower CP1500PFCLCD 1500VA/1000W for his gaming PC and ASUS monitor with a 5th Gen AirPort Extreme that we use as an access point. I thought it might be overkill, but I recall that he said the readout tells him that his PC, when under load, draws over 450W - and at half-load it says it will run for about 40 minutes. He thinks he could push his PC to draw up to 500W (I7-10700K overclocked on MSI Godlike MB with RGB everything and Corsair water cooler, 5 drives, 5 fans, RTX 2080 Super graphics, and Seesonic 1000w PSU).
For $199 at Best Buy, if you have the room I would recommend the CyberPower, which is $209 at Amazon. Based on what it says about my son's PC, I would guess that it could run the iMac for double what it told him while using it, and longer at idle or asleep.