The history of railways in Württemberg describes the beginnings and expansion of rail transport in Württemberg from the first studies in 1834 to today.

Starting points From the start of the 19th century, transport planning in the Kingdom of Württemberg revolved primarily around the construction of canals, which were meant to connect the rivers Neckar and Danube, and Lake Constance, with each other. As a result of the advent of railways elsewhere, King William I of Württemberg commissioned a study to determine whether the construction of railways instead of canals would be more appropriate. The report of the commission undertaking the study agreed and recommended the construction of a railway between Stuttgart and Ulm, running through the valleys of the rivers Rems, Kocher, and Brenz. Toward the end of 1835, additional demands developed in Ulm for a railway running from Stuttgart, via Ulm, along the Fils river, all the way to Lake Constance.

Despite the early and systematic state support of railway construction, it was another 10 years before the opening of the first railway in Württemberg. In the other larger states of the German Confederation (Deutscher Bund), such as Bavaria, Saxony, Prussia, Austria, Brunswick, Baden, and Hanover, at least one, and in some cases several, railways had been put into service by that time.

The late adoption was caused by the conclusion that the expensive construction of railways would not be cost-efficient in the relatively poor state. The total cost of building the main railways was thought to be about 30 million guilders, which was three times the state's annual gross domestic product. This relatively costly estimate was largely due to the hilly topography of Württemberg, and in particular the need to cross the Swabian Jura added to the expense. This mountain range splits the state into two sections, and the steep escarpment on the northern edge, the Albtrauf, posed a particularly challenging obstacle. In the southwestern part, the Black Forest formed part of the border with the neighbouring state of Baden. The planned routes, which were initially limited to running in river valleys, were also complicated by the interlocking of parts of the routes, such as in the Upper Neckar and Upper Danube valleys, with territory of the neighbouring states of Baden and Hohenzollern.

The construction of railways in neighbouring states, and the possibility of profits due to transit traffic, plus advances in railway engineering and technology, and the fear of being left behind by the development in the adjacent territories, finally provided the impetus needed to start railway building in Württemberg.

Construction of the main railways

The state government finally adopted the conclusions of the commission, and in 1836 formulated the plans for this initial list of main lines:

Ostbahn (Eastern line): 1st alternative: starting in Cannstatt, through the Fils valley, to Ulm, called the Fils Valley Railway (Filsbahn) 2nd alternative: starting in Cannstatt, through the valleys of the rivers Neckar, Rems, and Brenz, to Ulm, called the Remsbahn (Rems railway) Northern Railway (Nordbahn): from Cannstatt to Heilbronn Western Railway (Westbahn): branching off the Nordbahn near Eglosheim, and running toward the cities of Bruchsal or Pforzheim in Baden Southern (Südbahn): from Ulm to Friedrichshafen on Lake Constance

These plans were completed in 1839, and were revised by the surveyors von Negrelli, Charles Vignoles, and Karl Etzel. The resulting central questions were:

Routing of the Ostbahn: Using the Rems Railway alternative meant avoiding the Swabian Jura, but also meant a considerably longer route than the Fils Railway option, one which had to pass through Bavarian territory to boot. The direct route meant that the Geislinger Steige had to be conquered. Due to the better connection to Stuttgart, and the shorter distance to be covered, the Filsbahn alternative was chosen. Choice of the central station (Zentralbahnhof): The various plans had either Cannstatt, Stuttgart, or Berg as alternatives for the central railway station of the network. Because of the location of Stuttgart in the basin of a valley, initially plans called for a connection from Cannstatt or Berg via a secondary connection line only. Etzel later drew up plans that included modern engineering, including the Prague Tunnel and Rosenstein Tunnel, which made possible the location of the central station in the middle of Stuttgart. Since Stuttgart was by far the largest city of the three, and therefore passenger traffic expectation were highest, the decision was made to go with the Stuttgart location, even though its geographical location caused problems that still exist today (see Stuttgart 21).

The Royal Württemberg State Railways (Königlich Württembergischen Staats-Eisenbahnen or K.W.St.E.) were intended as state railways (Länderbahnen) from the beginning; applications for licences to operate private railway companies (for example, the Württembergischen Eisenbahngesellschaft, which had been founded as a private company in 1836) were initially denied. The government, and King, were interested in preserving the rights of the state with a view on the profits foreseen in the rail transit traffic between states. The negotiation of railway connection rights between the neighbouring states was a task for the state governments in any case.

On 18 April 1843, the Railway Law (Eisenbahngesetz) was passed, which legislated the creation of the railways listed above. The same law restricted the investment of private funds in the area of secondary connecting railways (Sekundärbahn). This law was also the impetus for the founding of the Maschinenfabrik Esslingen, which became the primary operator and designer of railway construction and railway technology in Württemberg.

After the passage of the law, the Zentralbahn (Central line) was the first line to be started, which connected Stuttgart via two separate branches with Ludwigsburg and Esslingen. Construction began in 1844, and the first section between Cannstatt und Untertürkheim was opened for service on 22 October 1845, with the entire line completed in 1846. The Nordbahn was completed in 1848, and the Ostbahn and Südbahn were completed in 1850.

The Westbahn required negotiations with Baden. These discussions were typical of the relationship of Württemberg with its neighbouring states, which was marked by both cooperation and competition. Both sides were convinced of the necessity of a railway connection on the one hand, but at the same time, both states were also interested in keeping the transit traffic from the north inside their territory as much as possible. Württemberg would have liked a connection between Heilbronn and Wiesloch, and Baden was inclined to grant a connection via Durlach–Pforzheim. By connecting in Bruchsal, a compromise was reached. As a result of these negotiations, the Westbahn was constructed between 1850 and 1853, and subsequently put into service. In 1854, a connection to the Bavarian railway network was achieved in Ulm.

The direct route Bretten–Stuttgart–Ulm developed into the most important railway axis in Württemberg, and it came to be known as the Hauptbahn (Main line).

Internal expansion

Even though the main lines turned out to be economically successful, a lull in railway construction commenced for the next several years. However, between 1854 and 1856 a steel mill for the manufacture of rails was built in Wasseralfingen near Aalen. Only in 1857 did the construction of railways restart in these areas of urgent need:

the upper Neckar region with the industrial city of Reutlingen and Tübingen the northeast of the state of Württemberg the east, with Aalen and Heidenheim, with eye on a connection to the Bavarian railway network near Nördlingen

Of these projects, the first to be realized was the Upper Neckar Railway, with the section Plochingen–Reutlingen completed in 1859, the expansion to Rottenburg in 1861, and to Eyach in 1864.

To open up the northeast of Württemberg, the initial plans called for a route from Heilbronn through the Kocher valley and via Hall to Aalen. Due to the technical difficulty of that route, it was abandoned and a route via Öhringen, Hall, and Crailsheim, then through the Jagst valley to Aalen was planned instead. However, the new Railway Law of 18 November 1858 legislated only the construction of the Kocher Railway to Hall, which was completed in 1862.

To get the railway into the east of Württemberg, in 1857 the state government had planned on a route branching off the Fils Valley Railway near Lonsee to Heidenheim. After further exploration, this plan was found to be uneconomical, and was abandoned. Branching off in Uhingen in the Fils valley to Lorch, and then running through the Rems valley to Aalen, was thought to have a better chance of being realized. This route also offered a better connection to the Upper Neckar Railway. However, Bavaria, which feared competition on its own north–south connection, indicated that it would not permit a connection to its railway network at Nördlingen. For this reason, the Rems Railway, running from Cannstatt to Waiblingen, and from there alongside the Rems river to Aalen and Wasseralfingen, was constructed, and opened for service in 1861. Also in 1861, the states of Württemberg and Bavaria signed a treaty, which codified the expansion of this line to Nördlingen, which was completed in 1863. However, that treaty did include an unfavorable clause for Württemberg, which prohibited the direct connection between Aalen and Ulm (later to become the Brenz Railway) until 1875. For this reason, it was just a branch line that was constructed in 1864 to connect Aalen to Heidenheim.

Connections to other states At the time of the construction of the Western Railway, Baden had secured the right to a possible connection in Mühlacker to a railway coming from Pforzheim. Baden completed this connection in 1863 (please see Karlsruhe–Mühlacker railway), which meant that Mühlacker on the Württemberg side became a railway node, and grew in a short time from a village to a small city.

Any additional expansion of the rail network required negotiations with neighbouring states. Along with Bavaria and Baden, these states included Prussia, whose territory of Hohenzollern bordered on Württemberg, and Hesse, whose exclave Wimpfen was situated between Baden and Württemberg.

In 1864, three northerly connection points to the Odenwald Railway (Heidelberg–Mosbach–Würzburg) in Baden were agreed upon:

from Heilbronn via Jagstfeld and Wimpfen to Meckesheim (now part of the Franconia Railway, Elsenz Valley Railway) from Heilbronn via Jagstfeld to Osterburken (now part of the Franconia Railway) from Crailsheim via Mergentheim to Lauda (Tauber Valley Railway)

A connection along the Neckar in the direction of Eberbach to the Hessian railway there, which was desired by Württemberg, did not materialize, due to opposition by Baden, which feared competition to its Rhine Valley Railway.

The above agreements meant the development of Jagstfeld and Crailsheim into railway nodes. The planned railways were constructed between 1866 and 1869, and Crailsheim was additionally connected to Goldshöfe station (on the Rems Railway) via the Upper Jagst Railway and Hall via the Hohenlohe Railway.

In the south, Württemberg planned to expand its Upper Neckar Railway via Horb am Neckar to Rottweil. In addition, another line was planned from Stuttgart to Horb, which was meant to speed up that connection. The latter was possible in two alternatives: via Böblingen and Herrenberg (now on the Stuttgart–Horb railway), or via Weil der Stadt, Calw, and Nagold (on the Black Forest Railway). Based on the estimated expense, the latter option was initially chosen.