A rail yard, railway yard or railroad yard is a complex series of railroad tracks for storing, sorting, or loading and unloading, railroad cars and locomotives. Railroad yards have many tracks in parallel for keeping rolling stock stored off the mainline, so that they do not obstruct the flow of traffic. Railroad cars are moved around by specially designed yard switchers, a type of locomotive. Cars in a railroad yard may be sorted by numerous categories, including railroad company, loaded or unloaded, destination, car type, or whether they need repairs. Railroad yards are normally built where there is a need to store cars while they are not being loaded or unloaded, or are waiting to be assembled into trains. Large yards may have a tower to control operations. :46
Many railway yards are located at strategic points on a main line. Main-line yards are often composed of an up yard and a down yard, linked to the associated railroad direction. There are different types of yards, and different parts within a yard, depending on how they are built.
For freight cars, the overall yard layout is typically designed around a principal switching (US term) or shunting (UK) technique:
- A hump yard has a constructed hill, over which freight cars are shoved by yard locomotives, and then gravity is used to propel the cars to various sorting tracks;
- A gravity yard is built on a natural slope and relies less on locomotives; generally locomotives will control a consist being sorted from uphill of the cars about to be sorted. They are decoupled and let to accelerate into the classification equipment lower down.
- A flat yard has no hump, and relies on locomotives for all car movements.
In the case of all classification or sorting yards, human intelligence plays a primary role in setting a strategy for the 'switching operations'; the fewer times coupling operations need to be made and the less distance traveled, the faster the operation, the better the strategy and the sooner the newly configured consist can be joined to its outbound train.
- Switching yards, staging yards or Shunting yards are typically graded to be flat yards, where switch engines manually shuffle and maneuver cars from: a) train arrival tracks, to a b) consist breakdown track, c) to an consist assembly track, thence to d) departure tracks of the yard.
- A large sub-group of such yards are known as Staging yards, which are yards serving an end destination that is also a collection yard starting car groups for departure. These seemingly incompatible tasks are because the operating or road company and its locomotive drops off empties and picks up full cars waiting departure which have been spotted and assembled by local switch engines. The long haul carrier makes the round trip with a minimal turn around time, and the local switch engine transfers empties to the loading yard when the industries output is ready to be shipped.
- This activity is duplicated in a Transfer yard, the difference being in the latter many or several businesses and industries are serviced by the local switcher, which is part of the yard equipment, and the industry pays a cargo transfer fee to the railroad or yard operating company. In the staging yard, the locomotive is most likely operated by industry (refinery, chemical company or coal mine personnel); and ownership of the yard in both cases is a matter of business, and could be any imaginable combination. Ownership and operation are quite often a matter of leases and interests 
- Hump yard and gravity yard tracks are usually highly automated and designed for the efficient break-down, sorting, and recombining of freight into consists, so they are equipped with mechanical retarders (external brakes) and scales that a computer or operator uses along with knowledge of the gradient of the hump to calculate and control the speed of the cars as they roll downhill to their destination tracks. These modern sorting and classification systems are sophisticated enough to allow a first car to roll to a stop near the end of its classification track, and, by slowing the speed of subsequent cars down the hump, shorten the distance for the following series of cars so they can bump and couple gently, without damaging one another. Since overall throughput speed matters, many have small pneumatic, hydraulic or spring-driven braking retarders (below, right) to adjust and slow speed both before and after yard switch points. Along with car tracking and load tracking to destination technologies such as RFID, long trains can be broken down and reconfigured in transfer yards or operations in remarkable time.
A large freight yard complex may include the following components:
- Receiving yard, also called an arrival yard, where locomotives are detached from freight cars, cars are inspected for mechanical problems, and sent to a classification yard;
- oft-called Switching yards or Switchyards or sorting yards—yards where cars are sorted for various destinations and assembled into blocks have different formal names in different cultural traditions:
- Departure yard where car blocks are assembled into trains;
- Car repair yard or Maintenance yard for freight cars;
- Engine house (in some yards, a roundhouse) to fuel and service locomotives. :58
- Transfer yard is a yard where consists are dropped off or picked up as a group by through service such as a Unit Train, but managed locally by local switching service locomotives.
- Unit tracks may be reserved for Unit trains, which carry a block of cars all of the same origin and destination, and so as through traffic do not get sorted in a classification yard. Such consists often stop in a freight yard for other purposes: inspection, engine servicing, being switched into a longer consist and/or crew changes. :52
Freight yards may have multiple industries adjacent to them where railroad cars are loaded or unloaded and then stored before they move on to their new destination.
Major freight yards in the U.S. include the Bailey Yard in North Platte, Nebraska, operated by Union Pacific Railroad; Conway Yard near Pittsburgh, operated by Norfolk Southern Railway; and the Corwith Yards (Corwith Intermodal Facility) in Chicago, operated by BNSF Railway.
Coach yards are used for sorting, storing and repairing passenger cars. These yards are located in metropolitan areas near large stations or terminals. An example of a major US coach yard is Sunnyside Yard in New York City, operated by Amtrak. Those that are principally used for storage, such as the West Side Yard in New York, are called "layup yards"  or "stabling yards."
- Kraft, Edwin (June 2002). "The Yard: Railroading's Hidden Half". Trains. Vol. 62 no. 6.
- The Lehigh and Susquehanna Railroad was builder and operator of Mountain Top Yard, whereas both were leased to the CNJ, rents and ownership being retained by the Lehigh Coal & Navigation Company.
- Chicago-L.org. "42nd Place Terminal." Accessed 2013-08-30.