The invention discloses a hydraulic cylinder, which comprises a cylinder tube, a piston, a piston rod and an end cap, wherein the piston is positioned in the cylinder tube and is used for separating the cylinder tube into a first cavity and a second cavity, the piston rod is positioned at one side of the piston and is fixedly connected with the piston, the end cap is fixedly connected with an opening port of the cylinder tube, the piston rod penetrates out of the end cap, the piston is provided with a limiting device, the limiting device comprises a first one-way valve, a second one-way valve and a first push rod, an oil outlet of the first one-way valve is communicated with a first cavity, an oil inlet of the first one-way valve is communicated with an oil inlet of the second one-way valve, an oil outlet of the second one-way valve is communicated with the second cavity, one end of the first push rod extends into the second cavity, the first push rod can slide along the cylinder tube in the axial direction, and then the other end of the first push rod jacks up a valve core of the first one-way valve. The hydraulic cylinder has the advantages that the power in the piston movement process is reduced, and the piston is prevented from colliding with the end cap or the bottom wall of the cylinder tube, so the cylinder tube is protected.