A thiazolidine derivative represented by the formula (I) wherein each symbol is as defined in the specification, and a pharmaceutically acceptable salt thereof exhibit a potent DPP-IV inhibitory activity, and can be provided as an agent for the prophylaxis or treatment of diabetes, an agent for the prophylaxis or treatment of obesity and the like.