Stans is one of the oldest settlements in the entire Nidwalden valley. The first traces of human settlement date to the 2nd Century BC. During the Roman era there is little evidence of a settlement except for some Gallo-Roman Ustrinum or funeral pyres and the Latin root (stagnum meaning a pool or sump) of the name Stans.
During the 7th or 8th Century the Alamanni settled in the region. The Christian Alamanni built the first church in Stans around 750 AD. This pre-Carolingian church served as the parish church for the entire Engelberg Valley. The church was expanded numerous times until it was finally replaced in 1647 by the new church of St. Peter and Paul.
Stans was first mentioned in 1124. By 1291, when Unterwalden joined Uri and Schwyz in what became the Swiss Confederation, Stans was already the capital of the section known as Unterwalden nid dem Kernwald which would become the half canton of Nidwalden.
In 1386, during the Battle of Sempach, a soldier from Stans, Arnold von Winkelried, is claimed to have thrown himself on the pikes of the Habsburg army which led the Swiss to victory. However it is doubtful whether he existed or died in the battle as the first mention of his selfless act appears over 150 years after the battle and a man who may have been Arnold was party to a lawsuit in 1389. Regardless, the legend is firmly in place in Stans, with a monument and his house located in the town.
Following the Swiss victories in the Burgundian Wars the Old Swiss Confederation was nearly torn apart by internal conflict when the city cantons insisted on having the lion's share of the proceeds since they had supplied the most troops. The country cantons resented this and the Tagsatzung or leadership of each of the cantons met in Stans in 1481 to resolve the issues. However, they were unable to resolve the issues and war seemed inevitable. A local hermit, Niklaus von der Flüe, was consulted on the situation. He requested that a message be passed on to the members of the Tagsatzung on his behalf. The details of the message have remained unknown to this day, however it did calm the tempers and led to the drawing up of the Stanser Verkommnis. As part of the Verkommnis Fribourg and Solothurn were admitted into the confederation.
In 1713 two-thirds of the town was destroyed in a fire. Following the fire, new regulations kept the village square (Dorfplatz) open and clear of construction. The large, open square surrounded by baroque houses and the town council house (Rathaus) owe their appearance to the fire and subsequent reconstruction.
In 1798 Stans was stormed by French troops, following the decision of Nidwalden not to adopt the constitution of the Helvetic Republic. Children orphaned by this event were gathered by the educator Johann Heinrich Pestalozzi for his first school. He converted the Convent of St. Klara (built in 1621-1625) into a school for the children. However, he only had the school until the following year when the French Army needed the building and the orphan's school came to a sudden end. In 1814, following the collapse of the Napoleonic Act of Mediation, Nidwalden attempted to return to the Ancien Regime government, with subject lands belonging to the canton. Stans and the rest of Nidwalden only gave up their subject lands when Federal troops marched into the city. Stans and the rest of Nidwalden joined the Sonderbund in 1845 and were involved in the 1847 Sonderbund War.
In the 20th Century, modern technology and transportation changed Stans. In 1893 Stans was connected to the rail network of Lucerne by steam ferry. In 1964 the Lucerne-Stans-Engelberg rail way was opened and in 1966 the A2 motorway (which is Switzerland's main north-south axis from Basel to Chiasso) was constructed.
The open-air assembly (Landsgemeinde) was held in Stans annually until its abolition in 1997.
The area of Stans is 11.08 km2 (4.28 sq mi). Much of the land within the borders of Stans is agricultural (43.7%), while just over a third (36.5%) is forested. Of the remaining area, about 17% is settlements and less than 2.6% is unproductive (mountains, rivers or glaciers). The highest point within the borders of Stans is on the Stanserhorn and is 1,819 m (5,968 ft) above sea level. The lowest point is at Fronhofen where the elevation is 438 m (1,437 ft). The village square (Dorfplatz) has an elevation of 452 m (1,483 ft).
Stans has an average of 137.7 days of rain per year and on average receives 1,224 mm (48.2 in) of precipitation. The wettest month is August when Stans receives an average of 166 mm (6.5 in) of precipitation on 13.6 days. The month with the most days of precipitation is June, with an average of 14.2, but with only 156 mm (6.1 in) of precipitation. The driest month of the year is January with an average of 65 mm (2.6 in) of precipitation over 13.6 days.
Stans has a population (as of 31 December 2018) of 8,393. As of 2007, 9.4% of the population was made up of foreign nationals. Over the last 10 years the population has grown at a rate of 13.2%. Most of the population (as of 2000) speaks German (91.6%), with Italian being second most common (2.0%) and Serbo-Croatian being third (1.2%). As of 2008 the gender distribution of the population was 48.6% male and 51.4% female. As of 2000 there are 2,816 households, of which 1,837 households (or about 65.2%) contain only one or two individuals. 202 or about 7.2% are large households, with at least five members.
Stans has an unemployment rate of 1.27%. As of 2005, there were 89 people (1.2%) employed in the primary economic sector and about 32 businesses involved in this sector. 2,463 people (34%) are employed in the secondary sector and there are 113 businesses in this sector. 4,601 people (65%) are employed in the tertiary sector, with 496 businesses in this sector.
Stans is served by Stans station on the Luzern–Stans–Engelberg line. Lucerne S-Bahn S4 service provides two trains per hour to and from Lucerne, and the hourly InterRegio service between Lucerne and Engelberg also stops in Stans.
The local mountain, the Stanserhorn (1,898 m (6,227 ft)) is also a tourist resort. It is accessible via one of the oldest mountain railways in Switzerland, the Stanserhornbahn (1893), and by cable car. The Stanserhornbahn was originally built as a rack and pinion railway, with three separate sections. In 1970 the upper section was destroyed by a fire following a lightning strike. In 1975 the destroyed upper section and the middle section were replaced by an aerial cable car. At the peak of the Stanserhorn is the Rondorama, a revolving restaurant that was built in 2001. From the peak of the Stanserhorn, on a clear day the view stretches nearly 100 km (62 mi) and includes 10 Swiss lakes and the Black Forest of Germany. There is a short hiking trail around the peak of the Stanserhorn and a small population of Marmots are kept near the trail.
Following the fire in 1713, the village square (Dorfplatz) was fully rebuilt, to its current unified appearance, in 1715 according to a plan by Josef Aebi and Ludwig Gassmann. The square now houses the Winkelried fountain and the sculpture Der Tod und das Mädchen (Death and the Maiden). The Winkelried monument was carved from Carrarain marble in Rome and then shipped by boat, rail and horse team to Stans in 1865. The monument is in a Gothic Revival style and was carved by Ferdinand Schlöth. Death and the Maiden was done by Rudolf Brem.
The Parish church, St. Peter und Paul was built from 1641 until 1647 by the architect Jakob Berger. The church was constructed in an early-Baroque style, while the bell tower is an older Romanesque structure. The three nave Basilica was built south of the earlier church, though the older bell tower dates from this previous church. The interior is decorated in white, gold and black. The simple interior ornamentation comes from Lombardy while there altar figures were done by Georg Allhelg. Next to the church is a two-story chapel and ossuary for the nearby Capucin monastery.
A Capucin monastery was established in Stans in 1583 by Melchior Lussy, who had been sent to the Council of Trent. Initially there was resistance to the poverty, simple habits and beards of this order of Counter-Reformation monks. In 1777 the monks opened a Latin school, which was suppressed from 1798 until 1803 under the Helvetic Republic. The Kollegium St. Fidelis was built by the monks in 1895 and purchased by the canton in 1988. The monastery church was built in 1683 and renovated in 1980. In 1956 a memorial tablet to Melchoir Lussy was placed near the gate of the monastery.
The Convent St. Klara was founded by Katharina and Maria Gut in 1618. The buildings were built from 1621-25. In 1799 Heinrich Pestalozzi established his orphanage and school in the convent buildings. The convent church (built in 1723) is a simple structure with an ornate altar by Johann Ritz and a mystical altar painting by Johannes Brandenburg. The church was renovated in 1980. From the convent cemetery a path leads to the nearby Capucin monastery.
A portion of the Winkelriedhaus (Winkelried House) was once home to the Winkelried family, though Arnold von Winkelried (if he existed) did not live in it. The oldest part of the structure dates from the middle of the 15th Century. The early house was an unusually tall and large half timbered (German: fachwerk, Alemannic German: Riegelbau) building, which was known throughout much of central Switzerland. However, it was not owned by the Winkelrieds for very long; in 1541 the Lussy family purchased the house. Under Melchior Lussy the Gothic building was renovated over a period of 50 years into a much larger, Renaissance mansion. In 1766 the Landammann (Chief Magistrate) Jost Remigi Trachsler bought the house. During much of the second half of the 18th Century he had the Winkelriedhaus renovated and added a number of rococo frescos on the walls of the house. In 1815, the Kayser family bought the house, which they held until 1974 when it was given to the canton. It was restored from 1983 until 1991 and since then has been the home of the Museum für Kultur und Brauchtum.
The Salzmagazin (lit. Salt storage house) was originally built to store grain and salt for the community in 1700. It has had many other uses since then including; a theater, a secondary school and finally a museum. The coat of arms of the builder and Landammann Nicolaus Keiser as well as two lions with the Nidwalden shield and two-header eagle are visible on the north gable.
In the front garden of the former Nidwaldner Kantonalbank is a monument by the Swiss sculptor August Stanser Blaesi (1903–1979) that was erected in memory of the local artist Melchior Paul von Deschwanden (1811–1881) in the autumn of 1933. Deschwanden was one of the most influential and productive religious painters of his time, trained in the Nazarene-style in Munich, Germany, who sent paintings to hang in Roman Catholic churches as far as Annapolis, Maryland and Covington, Kentucky. Amongst his pupils were Adalbert Baggenstos (1863–1897) from Stans, and the Swiss-born American portrait painter Adolfo Müller-Ury, in whose arms he died in February 1881.
- Melchior Paul von Deschwanden (1811 in Stans – 1881), religious painter
- Gustave Lussi (1898 in Stans – 1993), figure skating coach
- Hans von Matt (1899–1985), painter and sculptor, born and died in Stans
- Peter von Matt (born 1937), philologist and author, brought up in Stans
- Urs Odermatt (born 1955 in Stans), film director and author 
- Monika Hess (born 1964 in Stans), former alpine skier who competed in the 1984 Winter Olympics
- Bruno Amstad (born 1964 in Stans), singer in the field of improvisation and jazz
- Rochus Lussi (born 1965 in Stans), artist and art teacher and an independent sculptor in woodwork
- Seppi Hurschler (born 1983 in Stans), Nordic combined skier who has competed in three Winter Olympics
- Nicole Riner (born 1990 in Stans), retired tennis player
- Ayla Huser (born 1992 in Stans), badminton player
- Zoël Amberg (born 1992 in Stans), professional racing driver