Telegraph line between Los Angeles and San Francisco opens.

San Francisco (; Spanish for "Saint Francis"), officially the City and County of San Francisco, is a commercial and cultural center in Northern California. The city proper is the 17th most populous in the United States, and the fourth most populous in California, with 815,201 residents as of 2021. It covers a land area of 46.9 square miles (121 square kilometers), at the end of the San Francisco Peninsula, making it the second most densely populated large U.S. city after New York City, and the fifth most densely populated U.S. county, behind only four of the five New York City boroughs. Among the 331 U.S. cities proper with more than 100,000 residents, San Francisco was ranked first by per capita income (at $133,856) and fifth by aggregate income as of 2019. Colloquial nicknames for San Francisco include SF, San Fran, The City, Frisco, and Baghdad by the Bay.San Francisco and the surrounding San Francisco Bay Area are a global center of economic activity and the arts and sciences, spurred by leading universities, high-tech, healthcare, FIRE, and professional services sectors. As of 2020, the metropolitan area, with 6.7 million residents, ranked 5th by GDP ($874 billion) and 2nd by GDP per capita ($131,082) across the OECD countries, ahead of global cities like Paris, London, and Singapore. San Francisco anchors the 12th most populous metropolitan statistical area in the United States with 4.7 million residents, and the fourth-largest by economic output, with a GDP of $592 billion in 2019. The wider San JoseSan FranciscoOakland, CA Combined Statistical Area is the fifth most populous, with 9.6 million residents, and the third-largest by economic output, with a GDP of $0.5 trillion in 2020. Of the 105 primary statistical areas in the U.S. with over 500,000 residents, this CSA had the highest GDP per capita in 2019, at $112,910. In the same year, San Francisco proper had a GDP of $200.5 billion, and a GDP per capita of $228,118. San Francisco was ranked seventh in the world and third in the United States on the Global Financial Centres Index as of March 2022.As of June 2022, the Bay Area was home to four of the world's fifteen largest companies by market capitalization, and the city proper is headquarters to companies such as Wells Fargo, Salesforce, Uber, First Republic Bank, Airbnb, Twitter, Block, Levi's, Gap Inc., Dropbox, PG&E, Lyft, and Cruise, although the COVID-19 pandemic in the United States has accelerated the exodus of business from downtown San Francisco. The city is home to a number of educational and cultural institutions, such as the University of California, San Francisco (UCSF), the University of San Francisco (USF), San Francisco State University (SFSU), the de Young Museum, the San Francisco Museum of Modern Art, the San Francisco Symphony, the San Francisco Ballet, the San Francisco Opera, the SFJAZZ Center, the California Academy of Sciences, the San Francisco Giants, and the Golden State Warriors. A popular tourist destination, San Francisco is known for its steep rolling hills and eclectic mix of architecture across varied neighborhoods, as well as its cool summers, fog, and landmarks, including the Golden Gate Bridge, cable cars, Alcatraz, and Chinatown and Mission districts.

San Francisco was founded on June 29, 1776, when colonists from Spain established the Presidio of San Francisco at the Golden Gate and Mission San Francisco de Ass a few miles away, both named for Francis of Assisi. The California Gold Rush of 1849 brought rapid growth, transforming an unimportant hamlet into a busy port making it the largest city on the West Coast at the time; between 1870 and 1900, approximately one quarter of California's population resided in the city proper. In 1856, San Francisco became a consolidated city-county. After three-quarters of the city was destroyed by the 1906 earthquake and fire, it was quickly rebuilt, hosting the Panama-Pacific International Exposition nine years later. In World War II, it was a major port of embarkation for naval service members shipping out to the Pacific Theater. It then became the birthplace of the United Nations in 1945. After the war, the confluence of returning servicemen, significant immigration, liberalizing attitudes, the rise of the "beatnik" and "hippie" countercultures, the sexual revolution, the peace movement growing from opposition to United States involvement in the Vietnam War, and other factors led to the Summer of Love and the gay rights movement, cementing San Francisco as a center of liberal activism in the United States. More recently, statewide droughts in California have strained the city's water security.

An electrical telegraph was a point-to-point text messaging system, used from the 1840s until the late 20th century when it was slowly replaced by other telecommunication systems. At the sending station switches connected a source of current to the telegraph wires. At the receiving station the current activated electromagnets which moved indicators, providing either a visual or audible indication of the text. It was the first electrical telecommunications system and the most widely used of a number of early messaging systems called telegraphs, that were devised to communicate text messages more rapidly than by physical transportation. Prior to the electric telegraph, semaphore systems were used, including beacons, smoke signals, flag semaphore, and optical telegraphs for visual signals to communicate over distances of land.Electrical telegraphy can be considered to be the first example of electrical engineering, and was used by the emerging railway companies to develop train control systems that minimised the chances of trains colliding with each other. This was built around the signalling block system with signal boxes along the line communicating with their neighbouring boxes by telegraphic sounding of single-stroke bells and three-position needle telegraph instruments.

Text telegraphy consisted of two or more geographically separated stations (often called telegraph offices) connected by wires, usually supported overhead on utility poles (originally called telegraph poles). There were many different electrical telegraph systems invented, but the ones that became widespread fit into two broad categories.

The first category consists of needle telegraphs in which a needle pointer is made to move electromagnetically with an electric current from a battery or dynamo passing down the telegraph line. Early systems used multiple needles requiring multiple wires. The first commercial system, and the most widely used needle telegraph, was the Cooke and Wheatstone telegraph, invented in 1837. Early equipment sets used five needles to point to the letter being transmitted, but the cost of installing wires was more economically significant than the cost of training operators so a single-needle system with a code that had to be learned became the norm.

The second category consists of armature systems in which the current activates a telegraph sounder which makes a click. The archetype of this category was the Morse system, invented by Samuel Morse in 1838, using a single wire. At the sending station, an operator would tap on a switch called a telegraph key, spelling out text messages in Morse code. Originally, the armature was intended to make marks on paper tape, but operators learned to interpret the clicks and it was more efficient to write down the message directly. In 1865, the Morse system became the standard for international communication with a modified code developed for German railways. However, some countries continued to use established national systems internally for some time afterwards.

In the 1840s, the electrical telegraph superseded optical telegraph systems (except in France), becoming the standard way to send urgent messages. By the latter half of the century, most developed nations had created commercial telegraph networks with local telegraph offices in most cities and towns, allowing the public to send messages called telegrams addressed to any person in the country, for a fee. Beginning in 1854, submarine telegraph cables allowed for the first rapid communication between continents. Electrical telegraph networks permitted people and commerce to transmit messages across both continents and oceans almost instantly, with widespread social and economic impacts. In the early 20th century the telegraph was slowly replaced by teletype networks.