It is located approximately 20 kilometres (12 miles) northwest of the national capital Ljubljana, acting as the seat of the City Municipality of Kranj.
The nucleus of the city is a well-preserved medieval old town, built at the confluence of the Kokra and Sava rivers.
The city is served by the Kranj railway station on the route from Ljubljana to Munich, Germany (via Jesenice and Villach, Austria) and a highway.
In Kranj, the Kokra cuts deeply into the conglomerate, forming a canyon 40 meters (130 ft) deep.
Below Kranj, at Drulovka, the Sava forms a 40-meter (130 ft) deep canyon with conglomerate on both sides.
Kranj was attested in written sources in the 5th century and c. 670 as Carnium (and as via Chreinariorum in 973, actum Kreine in 1050–65, in loco Chreina in 1065–77, and Chrainburch in 1291).
The Slovene name is derived from Slavic *Korn’ь, borrowed from Romance Carnium in late antiquity.
Discoveries include a bronze ax found in Drulovka, Hallstatt-era graves in the northern part of the town above the bank of the Kokra River, testifying to Illyrian settlement, and a burial site in the southern part of the town above the left bank of the Sava River, indicating a Celtic settlement.
In the 6th century, a major Germanic settlement stood at the same site, and an Ostrogothic cemetery was discovered nearby.
Mills first developed along the Sava and Kokra rivers, and this was followed by butchers, fur merchants, hide and wood processors, and then weavers of canvas and woolen cloth.
The Protestant Reformation in Kranj was led by Gašpar Rokavec, who was succeeded by Jernej Knafel after his death.
[7] Economically, teamster services developed in Kranj in the 16th century, with connections to the rest of Upper Carniola and Carinthia.
Sieve-making also developed at this time; horsehair was imported from around Europe and the sieves were exported to France, Belgium, Germany, and Greece.
[7] During the Second World War, Kranj, along with the rest of northern Slovenia, was annexed by Nazi Germany.
[8] The German authorities dismantled the Jugo-Češka textile works, replacing the machinery with equipment to produce aircraft.
On 21 March 1944, German forces discovered several communist activists and functionaries at the Šorli Mill in Rupa in the northern part of the town, where military supplies for the Partisans were being stored.