The Kraichgau Railway (German: Kraichgaubahn  ⓘ) is a 64.8 km long railway line in the region of Kraichgau in northwestern part of the German state of Baden-Württemberg. It runs from Karlsruhe via Bretten and Eppingen to Heilbronn and was built in 1880. It gained international  renown in 1992 as the first dual-system rail/tram route of the Karlsruhe Stadtbahn, the section between Karlsruhe and Bretten being the prototype for the so-called Karlsruhe model.
 The western section of the line runs across the main direction of stream flows in the Kraichgau. These rivers flow in a north-westerly direction, while the line runs north east from Karlsruhe to Eppingen. The resulting transitions between mountains and valleys require a winding route with significant gradients. Overall, it crosses five mountain ridges between the valleys of the Pfinz, Walzbach, Saalbach, Kraichbach, Elsenz and Lein, requiring three tunnels. It only runs for a significant distance in a river valley between Flehingen and Sulzfeld, in this case the valley of the Kohlbach. In the eastern sections the natural conditions are favourable and the line runs largely through the valley of the Lein.
 Services on the Kraichgau Railway cross from the Karlsruhe tram network to the Albtal-Verkehrs-Gesellschaft network after crossing the A 5 and before running through the platforms of Karlsruhe-Durlach station, where they stop at platform tracks 11 and 12, which were built in 1992. There is provision for these platforms to be used by trams, including a turning loop northeast of the station. After crossing the Rhine Valley Railway, running between Karlsruhe and Heidelberg by a bridge on which Hubstraße Stadtbahn stop is located, and running parallel with the Karlsruhe–Mühlacker railway, it changes its safe-working system from the tram operating procedures (BOStrab) to rail operating procedures EBO shortly before Grötzingen.
 The Kraichgau Railway branches off at Grötzingen Oberaustraße station, running from Jöhlingen West to Wössingen Ost as a two-track line. At Bretten station it passes over the Württemberg Western Railway on a bridge, which is now served by Karlsruhe Stadtbahn line S 9 and regional service R 91. It has sections of double track from Bretten-Gölshausen to Gölshausen Industriegebiet and Eppingen West to Epping station. The only other sections of double track are near stations. After Eppingen the Steinsfurt–Eppingen line branches off to the left. The Kraichgau Railway is duplicated from Leingarten West. Shortly before Heilbronn Hauptbahnhof, the line crosses the Franconia Railway on the flat and the Stadtbahn services leave the Kraichgau Railway to run over tram tracks to the station forecourt and through the city of Heilbronn.
 By 1870, the central Kraichgau was surrounded by four railway lines. These are:
 The square surrounded by these lines comprises a vast territory on the border of Baden and Württemberg around the Baden city of Eppingen. These diverted the traditional trade routes and threatened the general economic development of the Eppingen region, which as a result sought the construction of a railway through the region in order to overcome this disadvantage. The Württemberg city of Heilbronn, which desired better transport links to the west, and Karlsruhe supported this proposal.
 This gave rise to a plan for a line from Karlsruhe (more precisely Grötzingen) via Bretten and Eppingen to Heilbronn. In addition to the local needs, the proposed line was also seen to play a role in the larger context, namely the idea of a possible direct line from France towards Nuremberg and from there to the east. Such a direct connection was supported in Heilbronn in preference to a purely Baden route that would have connected Bretten to the Meckenheim–Jagstfeld railway.
 The project received approval from state authorities in both countries. The Baden government was not able to quickly implement construction, as it was busy with other railways (mainly the Black Forest Railway). To accelerate construction, the city of Karlsruhe, under Mayor Wilhelm Florentin Lauter, offered to build the Baden section to Eppingen as directed with the Grand Duchy of Baden State Railway to operate the line, initially paying rent and later buying the line by instalments.
 The government of Baden went along with this proposal, and so the law authorising its construction was passed on 30 March 1872. Before construction could begin, however, negotiations had to be carried out with Württemberg. This resulted in a treaty agreed to on 29 December 1873, which envisaged other connections between the states in the Neckar Valley and the Kinzig Valley. Württemberg would build the Heilbronn–Eppingen section; Eppingen was identified as the interchange station. The Baden section would cross the Western Railway in Bretten. This was operated along its entire length by Württemberg, including the section through Baden territory between Ruit (near Bretten) and Bruchsal. In order to avoid the operation of a Württemberg-owned railway through Baden territory, Baden claimed the right to repurchase the section the Western Railway situated on its territory, which was its right under the treaty that originally authorised its construction. The negotiations dragged on over several years until a treaty was signed on 15 November 1878 that enabled Baden to acquire the Bruchsal–Bretten section.
 Because the Baden railways had a financial crisis, the city of Karlsruhe found it difficult at first to find a contractor to build the line, so that it was not until 15 November 1876 that a contract could be issued. The contractor was Ph. Holzmann & Cie. of Frankfurt am Main. On 15 October 1879, the line was opened from Grötzingen to Eppingen, on 10 October 1878, the Royal Württemberg State Railways opened the section between Heilbronn and Schwaigern and, on 7 August 1880, the gap was closed between Eppingen and Schwaigern. Planning and construction of the Württemberg section came under construction supervisor (Oberbaurat) Carl Julius Abel. During the discussion of the remaining section of the route the council of the then independent municipality of Stetten am Heuchelberg presented the designers with a fait accompli: it built a local station before it was clear that the line would pass through the site at all.
 With the completion of the line, the Baden State Railway took up the provision of the original agreement, taking full ownership of the railway, by taking over the balance of Karlsruhe's borrowing for the line for 12 million marks. Patronage on the Kraichgau Railway steadily increased in subsequent years.
 In 1900, the Steinsfurt–Eppingen line was opened connecting the Kraichgau Railway to the Meckenheim–Jagstfeld line. This line runs was along the Elsenz.
 The towns of Dürrenbüchig and Gölshausen (now both districts of Bretten) that are located on the Kraichgau Railway had complained about not having stations. Their wishes were finally granted in 1906. In 1888 the Bretten–Eppingen–Heilbronn section of the line was duplicated as part of a military supply route from central Germany via Nuremberg, Crailsheim, Heilbronn, Bretten, Bruchsal, Zweibrücken in the Saarland to Lorraine. The importance of the connection in peacetime, however, remained low, and the administrators of the Kraichgau Railway did not listen to requests for fast trains between Karlsruhe and Würzburg/Nuremberg. However, due to overloading at Stuttgart from 1906 to 1914, a luxury train, the "Paris–Carlsbad Express" ran over the Kraichgau Railway. It was considered to be a branch of the Orient Express running via Nuremberg to Carlsbad. The outbreak of the First World War, however, brought an end to this service.
 On 31 March 1920 the Baden and Württemberg State Railways were absorbed into the newly founded Deutsche Reichsbahn. Because Germany had to pay war reparations, having lost World War I, there were no funds for further upgrading of the line. Efforts were made in subsequent years to duplicate the remaining single section between Durlach and Bretten, without success. From 1935, the so-called Dieseleiltriebwagen (express diesel railcars) of class VT 137 were used on the line.
 Towards the end of the Second World War the Kraichgau Railway, like most other German railways, suffered significant damage. As the German army had blown up bridges in Grötzingen and Rinklingen and the line between Karlsruhe and Bretten was impassable for several months, services between Karlsruhe and the Kraichgau had to operate via Bruchsal. At the same time some track was dismantled to allow the re-opening of the Bietigheim viaduct on the only rail link between Karlsruhe and Stuttgart in August 1945.
 The era of scheduled steam operations ended in May 1972. From now on services on the Kraichgau Railway were operated with multiple units and locomotives of class 218 and class 212 hauling Silberling carriages. From 1976, Deutsche Bundesbahn published plans to close the line, together with the line between Eppingen and Sinsheim. So it had dismantled most of the continuous double-track section between Bretten and Heilbronn, replacing it with single track. The closure plans then stirred fierce opposition in the community.
 In the late 1980s, Class 628 DMUs took over passenger operations. At the same time operation between Bretten and Heilbronn on the weekends were sometimes altered.
 As a result, the Albtal-Verkehrs-Gesellschaft (Alb Valley Transport Company, AVG), an undertaking of the city of Karlsruhe, took over, from about 1990, the funding of the modernisation and electrification of the line as a pilot project. The  electrification system used was the usual Deutsche Bahn system of 15 kV AC.
 The Karlsruhe–Bretten-Gölshausen section of the line was opened on 25 September 1992 as line B of the Karlsruhe Stadtbahn network; the first Stadtbahn line, which had operated since 1975 on the Alb Valley Railway, was renamed as line A. While the latter was operated continuously with 750 V direct current, the Kraichgau Railway was the world's first line that changed over the course of its journey from tram and rail operating procedures in addition to the change between AC and DC. This form of operations is known as tram-train and its adoption on the Kraichgau Railway was the final step in the development of the Karlsruhe model.
 While the existing stations were modernised, several new stations were established, especially in the town of Bretten, for example, Bretten Stadtmitte in central Bretten. The AVG also restored several sections of double track, while a continuous second track was created from Jöhlingen West to Wössingen Ost. Since all tunnels were built for two tracks, the continuous electrification of the line was possible without great effort because the single track could be moved to the middle of the tunnels.
 The success of the new Stadtbahn line was immediate: instead of the previous average of 1,800 passengers using the line between Karlsruhe and Bretten, in early 1993 it was used by 8,500 passengers per day. Patronage even grew on Deutsche Bundesbahn's DMU services on the line.
 There were now regular services on Sundays, leading to an increase in the number of rail passengers by up to 30 times. So an extension of Stadtbahn route from Bretten seemed to make sense. In 1996, the remaining DB through trains between Karlsruhe and Heilbronn were abandoned. Henceforth, these only shuttled between Bretten-Gölshausen and Heilbronn.
 On 1 June 1997, Stadtbahn services were extended as far as Eppingen, with DB trains operating between Eppingen and Heilbronn. On 26 September 1999, the Stadtbahn was extended to Heilbronn station, following the operation of trial Stadtbahn services between Eppingen and Heilbronn on weekends from March 1999. In 2000, Bretten station was modernised. Since 2001, the trains on the Kraichgau Railway run from Heilbronn station through the city centre and since 2004 though Heilbronn's eastern suburbs. On 10 December 2005 Stadtbahn services were extended to Öhringen after two years of construction on a section of the Hohenlohe Railway.
 With a length of 155 km and a travel time of more than 3.5 hours, the Kraichgau Railway became in 2003–2004 part of the longest light railway line in the world, as a continuous run from Freudenstadt on the Murg Valley Railway to Karlsruhe and on to Heilbronn. As these services were prone to delays, they were abandoned with the extension of Stadtbahn services to Öhringen and the alignment was changed to run to Baden-Baden and Achern. The 2005/2006 timetable included a daily continuous service between Freudenstadt and Öhringen with a journey time of 4:14 h.
 The electrified line is now operated by the Albtal-Verkehrs-Gesellschaft as a section of line S 4 (Öhringen–Heilbronn–Karlsruhe–Rastatt–Achern) with modern electric Stadtbahn vehicles of class GT8-100C/2S and GT8-100D/2S-M. On the sections between Karlsruhe Albtalbahnhof (AVG station) and Karlsruhe Durlach and between Heilbronn Hauptbahnhof and Heilbronn Pfühlpark the services run on tram lines through streets. AVG has leased the line between Karlsruhe-Grötzingen and Heilbronn from Deutsche Bahn for 25 years.
 The Karlsruher Verkehrsverbund (Karlsruhe Transport Association, KVV) and the Heilbronner Hohenloher Haller Nahverkehr (Heilbronn Hohenlohe Hall Local Transport, H3NV) coordinate fares on the line on either side of Eppingen. Other transport associations are also affected.
 The platform height above rail level in Wössingen Ost, Bretten, Gölshausen Industrie and all stations between Eppingen and Heilbronn is 55 cm, thus making possible level access to the Stadtbahn vehicles of class GT 8-100D/2S-M. All other stations have a platform height of 38 cm.
 All platforms have a minimum length of 120 m, so that during periods of very high traffic load—especially in the morning peak of work and school transport—three sets of multiple units can be coupled. But, because the central on-street sections in Karlsruhe and Heilbronn are designed only to handle two sets coupled and because of the difficulty of separating and recombining trains for the inner city sections, trains rarely run at maximum length.
 The section from Grötzingen (km 0.0) to beyond Eppingen (km 43.5) has the official route number 4201; the following section to Heilbronn (km 140.0 to 118.6) is part of route 4950, which continues to Crailsheim. The zero point for the measurement of the chainage on the Hohenlohe Railway is at Goldshöfe station on the Upper Jagst Railway.
 The subsequent stops in Heilbronn's city centre are Bahnhofsvorplatz (with change from EBO to BOStrab procedures and electrification system), Neckar Turm am Kurt-Schumacher-Platz, Rathaus, Harmonie, Friedensplatz, Finanzamt and Pfühlpark. Directly after this station Stadtbahn services operate over a ramp to connect back to the Hohenlohe Railway with a reversal of safeworking procedures from BOStrab to EBO and of the electrification system.
 Through trains run between Karlsruhe and Heilbronn twice an hour, with one of the services operating as an "express train" with a smaller number of intermediate stops. The travel time between the central squares of the two cities by the stopping trains is 98 minutes and it is 81 minutes by the express trains.
 Although the Kraichgau Railway connects the cities of Karlsruhe and Heilbronn, freight traffic between the two cities was never significant. Agricultural traffic from the fertile Kraichgau was of significance for the line, especially for the removal of sugar beet during the beet harvest. Deutsche Bahn abandoned this form of transport by the end of 1993 on the  Kraichgau Railway as well as on all other railway lines in Baden-Württemberg. In 2001, the complete cessation of freight traffic on the line was considered as part of the rationalisation of freight operations known as MORA C. Then AVG took over passenger and freight transport on the Kraichgau line between Bretten and Heilbronn, while between Karlsruhe and Bretten there was for some time no freight traffic.
 Currently (May 2006) the AVG regularly serves freight sidings in Eppingen (two metal-processing companies and the Raiffeisen cooperative) and in Sulzfeld (a metal processing company).