The invention discloses an environment-friendly cleaning agent for mechanical equipment. The environment-friendly cleaning agent comprises the following raw materials in parts by weight: 25-35 parts of a luffa extract, 33-45 parts of a lemon extract, 26-36 parts of a gleditsia sinensis extract, 12-22 parts of lauryl sodium sulfate, 5-16 parts of alkyl glycoside, 2-6 parts of a preservative, 1-5 parts of an antibacterial agent, 1-3 parts of a viscosity regulator, 2-6 parts of a foam stabilizer, 1-4 parts of an essence, and 45-59 parts of deionized water. The cleaning agent is prepared through the following steps: cleaning luffa, lemons and gleditsia sinensis lam, respectively placing cleaned luffa, lemons and gleditsia sinensis lam in a pulverizer for pulverizing, extracting with ethanol, concentrating to obtain the luffa extract, the lemon extract and the gleditsia sinensis extract, mixing lauryl sodium sulfate, alkyl glycoside, the foam stabilizer and deionized water, stirring, adding the luffa extract, the lemon extract, the gleditsia sinensis extract and the viscosity regulator, heating, stirring, cooling, adding the preservative, the antibacterial agent and the essence, stirring and obtaining the cleaning agent. The environment-friendly cleaning agent is strong in stain removal and adsorption capability, has the characteristics of being non-toxic, environment-friendly and safe, and does not corrode and damage the mechanical equipment.