Hareskovbanen (English: the Hareskov line) is one of six radial S-train lines in Copenhagen. It connects the city center to a number of northwestern suburbs and the cities of Værløse and Farum, with the terminus placed in the latter.
The line was opened in 1906 as part of the private København-Slangerup Jernbane which went to Slangerup, about two thirds from Farum to Frederikssund. Its terminus in Copenhagen was København L, close to present day Nørrebro station on the S-train ring line - the station building of this station still stands. This was quite a bit from the city center, but the station was supposed to be temporary until the exact routing of the various new railways near Copenhagen that were in planning around the turn of the century had been finalized.
For the first many years, a large part of the traffic consisted of leisure trips by the large working population of Nørrebro to the Hareskoven forest.
Over the years, the economy of the private railway company declined, and in 1929 most of the private investors sold their shares to the municipalities along the line. After World War II the railway was so run down that the state railways DSB had to take it over in 1948. A few years later, in 1954, the outer end of the line between Farum and Slangerup was abandoned as it was unprofitable.
Plans to convert the line to S-trains had been discussed for decades, and in 1961 an act authorizing DSB to electrify the line. However, the act was not followed by sufficient allocations of public money, and it would take until 1977 until S-trains could begin running on the line.
Originally the plan was to extend the line as an underground line directly from København L to the center of the city, but over the course of the 1960s it became clear that the funding environment would not support metro construction in the foreseeable fututure. Therefore, in the eventual S-train conversion the innermost few kilometers in the line were abandoned and replaced by a large S-curve that connected it to the existing S-train trunk at Svanemøllen. A new overpass and interchange with the ring line was built at Ryparken. København L was abandoned and the terminus of the diesel trains moved to Svanemøllen in early 1976, and a year and a half later the conversion to S-trains were complete. This was the longest single addition to the S-train network so far.