Adulterated cooking oils and the repeated use of frying cooking oils are harmful to human health. Current techniques for the quality control of cooking oils such as gas chromatography and high performance liquid chromatography usually require expensive facilities, and they are complicated to operate. This paper describes a simple technique that uses magnetic levitation (MagLev) to analyse cooking oils based on density. We have demonstrated the application of MagLev to detect the quality of cooking oil by simulating adulterated sesame oil using peanut oil and frying soybean oil for different times. We have also demonstrated the use of MagLev to differentiate secondhand cooking oil from certified cooking oil. MagLev provides a portable and inexpensive method for the on-site inspection of cooking oils, and it may be extended to many other applications in food safety, environmental monitoring, medical diagnosis, and so on. The advantages of high sensitivity, low cost, and convenience of operation make MagLev especially useful for in situ applications in resource-limited settings.