Yes, some iMac models can be used as external monitors for other devices. This feature is called "Target Display Mode." However, not all iMac models support this feature.
iMac models released before late 2014 typically support Target Display Mode, which allows you to connect another device such as a MacBook or another computer to the iMac and use it as a secondary display.
To use Target Display Mode, you'll need a compatible cable to connect the two devices. For example, you might use a Thunderbolt or Mini DisplayPort cable to connect your MacBook to the iMac.
It's important to check the specific model of your iMac and its compatibility with Target Display Mode before attempting to use it as a monitor.