In engineering, a solenoid is a mechanical device that converts energy into linear motion. Solenoids can be constructed to use electricity, compressed air (pneumatic solenoids), or pressurized fluids (hydraulic solenoids).

An electrical solenoid is a form of electromagnet. In its simplest construction it consists of a number of turns of conductive wire through which a current is passed. This creates a magnetic field which is concentrated at the centre of the windings. Any ferromagnetic material that is brought into proximity is attracted by the magnetic field. Generally the construction is arranged so that the ferromagnetic material is presented as a plunger within the coil which is free to move in and out and is held out by a spring when the current is switched off.

Much more efficient solenoids are made by winding the coil around a ferrous C-shaped core and using a T-shaped ferrous core. When a current flows, this structure creates a tight magnetic loop, the T fitting into the C and touching at the lip and bottom.

A pneumatic solenoid is designed much like the piston in an automobile engine. The housing consists of a hollow tube, usually metal, that is capped on either end. Both ends have 1 or more ports for intake and exhaust. The actuator itself is connected to the piston by a rod that passes through the center of one end. To stroke the solenoid pressure is applied to one end of the device, while the other end is allowed to vent. To reverse the movement pressure is applied to the opposite side of the piston. Industrial solenoids are capable of applying enormous pressure using relatively low pressure supplies. The larger the diameter of the housing, the greater the force applied to the actuator for a given supply pressure.

Hydraulic solenoids are in general similar to pneumatic solenoids except that they are more durable, with tighter tolerances and exert much higher forces. Hydraulic breaks use solenoids to bend sheets of titanium in aerospace manufacturing, for example.