A Flat-12 is an internal combustion engine in a flat configuration, having 12 cylinders.

The flat-12 is wider (but significantly lower in height) than a V12 . Despite the advantage of having a lower center of gravity than a V12, that advantage can be somewhat offset by the need for a higher mounting height in the engine bay to provide clearance for the exhaust system (six runners on either side). Whereas a V12 can be used in front-engined or mid-engined applications, a flat-12 is used exclusively in mid-engined sports cars. In addition, because it has no advantage in terms of vibrations compared to the more commonly used V-12, the design is rarely used on production cars.

Flat-12 engines are generally not true horizontally opposed engines (boxer), but rather 180° V-engines. A true boxer has one crank pin per piston, while in the 180° V-engine, two opposing pistons share the same crank pin.

The flat design was used in Formula One and Endurance racing. However, when wing-cars requiring air-flow venturis came along in the late 1970s, the wide, flat layout obstructed the airflow and became obsolete.

In 1964-65, at the end of the 1.5 litre F1 era, Ferrari introduced a flat-12 on the Ferrari 1512 F1, but a more classical V12 was chosen for the new 3 litre F1.

The Porsche 917 endurance racing car (introduced in 1969, for the Sport category) was powered by an air-cooled flat-12. This engine was an evolution of the Porsche flat-8 boxer engine and used identical cylinders to those found on the 908, but differed in that it used a V12 type crankshaft. The domination of the Porsche 917 over the V12-powered Ferrari 512 probably influenced Ferrari, because they returned to the flat-12 in 3 litre water-cooled form for their prototypes and Formula One cars.

The Ferrari flat-12 design was successful and influential especially on Italian manufacturers, including Alfa Romeo, who were also successful in endurance racing with a flat-12. The Tecno Formula One flat-12 was a failure, however.

A 4.4-5.0 L 180° flat-12 was later introduced by Ferrari in some of their production models, including the Berlinetta Boxer and Testarossa.

Motori Moderni designed a 3.5 litre flat-12 engine for Subaru, which would be used in the 1990 Coloni Formula One car. The Coloni−Subaru was not competitive and did not start a Grand Prix. The Motori Moderni flat-12 engine also appeared in detuned form in the Jiotto Caspita supercar. This only appeared in a single prototype and was not put into production.

In the early 1990s, Mercedes-Benz built their 3.5 litre M-291 flat-12 engine for endurance racing. This engine employed a clever cylinder-head design in which the exhaust ports are located where the intake ports would normally be (on top of the engine, pointing upwards). The intake ports are then re-located between the intake and exhaust camshafts, just above the spark-plugs, pointing at an outward angle from the vertical. By locating the entire exhaust system on top, rather than underneath the engine, a much lower mounting height was achieved for this engine in the engine-bay of their racing car, the C-291 (and later C-292). Unfortunately, the engine suffered from oil scavenging problems early on in its development, and although the problem was eventually solved, changes in the rules by FIA and ACO effectively doomed the future prospects of what could otherwise have been a competitive engine.

Henry Meadows built a flat-12 petrol engine in World War II for the British Covenanter tank. In 1954, Panhard fitted a flat-12 (based on its earlier aircooled two-cylinder) in the EBR armored car.