{{for}}
{{Infobox block
| group = Straight (North to South)
| 1-1 = Rail (NS).png 
| group2 = Straight (West to East)
| 2-1 = Rail (EW).png 
| group3 = North - East
| 3-1 = Rail (NE).png 
| group4 = East - South
| 4-1 = Rail (ES).png 
| group5 = South - West
| 5-1 = Rail (SW).png 
| group6 = North - West
| 6-1 = Rail (NW).png
| transparent = Yes
| light = No
| tool = pickaxe
| renewable = Yes
| stackable = Yes (64)
| flammable = No
| lavasusceptible = No
| waterloggable = Yes
}}
'''Rails''' are non-solid [[block]]s that provide a path along which [[minecart]]s can travel.

== Obtaining ==
=== Breaking ===
Rails can be mined with anything, but [[pickaxe]]s are the quickest.

{{breaking row|horizontal=1|Rail|pickaxe}}

A rail also drops as an [[item (entity)|item]] when the block beneath it is removed, or a [[piston]] moves it into a space with no block below it.

=== Natural generation ===
Rails can be found naturally running along the floor in [[mineshaft]]s, both in the center of tunnels and under loot [[chest minecart]]s, and in the "pumpkin ring room" of [[woodland mansion]]s.

{{Block distribution}}

=== Generated loot ===
{{LootChestItem|rail}}

=== Crafting ===
{{Crafting
|A1= Iron Ingot
|C1= Iron Ingot
|A2= Iron Ingot
|B2= Stick
|C2= Iron Ingot
|A3= Iron Ingot
|C3= Iron Ingot
|Output= Rail,16
|type= Transportation
}}

== Usage ==
{{see also|Tutorials/Minecarts}}
A rail can be used as a minecart track and as a redstone component. A sequence of rails (including regular rails, [[activator rail]]s, [[detector rail]]s, and [[powered rail]]s) is called a '''track'''.

=== Placement ===
To place a rail, {{control|use}} a rail item while pointing at a surface facing the space the rail should occupy. A rail can be placed on:
* the '''top''' of any full block (stone, dirt, blocks of gold, glass, etc.), including full-block mechanism components ([[command block]]s, [[dispenser]]s, [[dropper]]s, [[note block]]s, and [[redstone lamp]]s)
* the '''top''' of an upside-down [[slab]], upside-down [[stairs]], or [[trapdoor]].
* any of the above underwater (making the rail [[waterlogged]])

Rails visually float {{frac|1|16}} blocks above the ground, with an [[Hitbox#Outline_box|outline]] {{frac|2|16}} blocks high.

A rail cannot be attached to the side or bottom of any block, but attempting to make such an attachment may cause the rail to attach to the top of a block under the destination space. For example, if a fence is on the ground, attempting to attach a rail to the side of the fence causes the rail to be attached to the top of the ground next to the fence instead.

More information regarding placement on transparent blocks can be found at [[Opacity/Placement]].

A placed rail configures itself to be straight or curved according to rail blocks around it. 
* If there are no other rails adjacent, or if placed beside an existing stretch of track of any type, then {{in|bedrock}} the new rail orients itself as a straight north-south track, and {{in|java}} the new rail orients itself in the direction the player is facing.
* A new rail placed at the end of an existing stretch of track continues the existing track in the same direction, either east-west or north-south.
* If there are two adjacent rails on its level, or one level up or down, the newly placed rail configures itself as straight or curved as needed to connect the other two.
* If placed between three adjacent rails (forming a T-junction) the newly placed rail configures itself as curved to join two of the sides.
<gallery mode="packed">
Teesbeforefilling.png|T-junction before filling in tracks
Tjunctionsafter.png|T-junction after filling in tracks
</gallery>
Existing tracks one block up and down are considered for adjacency in the same manner, and the new piece of track gets laid as a curve, but unless space is left for sloping track sections, minecarts can continue past the curve only on level or one-block-down corners. In one-block-up corners, the cart ends up buried in the ground.
<gallery mode="packed">
3wayoneblockup.png|Before placing the top block.
3wayoneblockupplaced.png|Top block is placed as curve.
3wayoneupcart.png|Showing cart getting buried.
</gallery>
Some placement of rails produces track layouts that cause minecarts to collide and enter blocks.
<gallery mode="packed">
Updowntooclose.png|Minecarts always buried
Updowngoodspacing.png|Minecarts get through
</gallery>
* If placed to form a 4-way intersection with no curved section, it does not form a cross-roads connection.
* If placed between four adjacent rails to form a curved intersection it always curves south-to-east.
<gallery mode="packed">
4wayjoined.png|Curve controls minecart passage
</gallery>

Existing sections of track may be re-oriented, become sloping, or even change into curved sections when the new rail is placed adjacent to it:
* An existing straight, north-south rail re-orients to east-west when a new rail is placed at the east or west sides.
* If placed next to an existing rail that is one block up or down, the new rail slants up or down to join it. Rail "prefers", in order: west, east, south, and north. Other configurations can be created by placing and removing rails.
* If a track is placed perpendicular to an existing length of track, it appears as a straight rail, but in fact, it is curved according to the patterns for tee junctions as seen above; mine carts going through the intersection turn the corner. Breaking and re-laying track so that the intersection block is laid last causes the intersection block to be updated as a curved section.

==== Piston interactivity ====
Rails can be pushed and pulled by [[piston]]s. Pushing a rail upward may cause adjacent rails to become slanted. Subsequently pulling the rail back down again causes those newly-slanted rails to break because they are no longer supported on their upper end.

=== Redstone component ===
The intersection rail at a T-intersection may be made to change its direction of curvature by applying redstone power.
<gallery mode="packed">
File:Teeswitchleft.png
File:Teeswitchright.png
File:Teeswitchnoeffect.png
</gallery>

Separate tracks are laid adjacent, but at the next level, lower or higher can sometimes cause issues. However, normally they do not interact with the switched rail.

=== Minecart behavior ===
==== South-east rule ====
[[File:Track intersections.png|left|thumb]]
[[File:T-intersection-south-west.png|right|thumb]]
{{main|South-east rule}}
A minecart travels straight through a T-shaped intersection when entering from the "back of" the curved rail. It follows the curve when entering from either of the other two legs.

A minecart passes straight through a 4-way intersection constructed to have no curved rail. When entering the 4-way from east or west a cart turns according to the south-east rule.
{{-}}

==== Downhill rule ====
[[File:Downhill rule.png|thumb]]
At non-curve track intersections, minecarts always travel downhill if they can. This is known as the downhill rule and overrides the south-east rule.
{{-}}

==== Ramp clearance/one-way effect ====
[[File:Minecart Block Passing Effect.png|thumb]]
A block placed above the track at the downhill end of a ramp prevents minecarts from traveling down the slope, but not up. For a minecart to move down a diagonal tunnel, there must be clearance sufficient for a player to walk it.
{{-}}

==== Curve intersections ====
[[File:Railguide.png|thumb|A diagram on how minecarts travel according to track curves.]]
If a straight track piece leads to a curve block and isn't attached to the curve, a minecart runs over the gap and continues to go straight over the curve. This is not applicable to other types of rails.

Notably, the minecart can exceed the normal 8&nbsp;m/s speed limit while it jumps over the gap. For example, by placing intersections on every other block of a straight track, it is possible to travel (uncomfortably) at 10&nbsp;m/s in a straight direction.

As with straight T-intersections and 4-way intersections, the practice of making a minecart jump track can be used to make one-way entries onto a track. On curve intersections the behavior is more intuitive because the cart simply proceeds in the direction it is already going, allowing designs that don't rely on the south-east rule.
{{-}}

==== Rail performance ====
To ascend from 0 to max speed, most minecarts needs 7 powered rails (a [[minecart with furnace]] has a lower top speed). After a certain number of rails, a minecart begins slowing down. This slowdown can be negated with a powered rail. A certain number of rails followed by 1 powered rail can then be repeated indefinitely to maintain full speed with the minimum amount of powered rails.

{| class="wikitable"
! Minecart type
! Initial maximum rails at full speed
! Subsequent maximums
|-
| Empty [[minecart]] and [[minecart with TNT]]
| 7
| 3
|-
| Minecart with entity
| 112
| Alternates between 38 and 26
|-
| [[Minecart with chest]] and [[minecart with hopper]]
| 85
| 20, then 29 onward
|}

For example, a minecart with an entity would require 112 rails, then 1 powered rail, then 38 rails, then 1 powered rail, then 26 rails, then 1 powered rail, then 38 rails, etc. Note that these rails can go in any direction: going 112 rails diagonally would still require a powered rail.

A minecart with no rider at full speed can climb 10 blocks on an unpowered track. This suggests that a powered track is needed at a height of only 10 blocks to keep a cart climbing. However, the cart slows so much that it can reach only another 5 blocks high with 2 lengths of powered track starting at 9 blocks high. The minimum number of powered rails to keep the cart climbing perpetually is 3 every 6 blocks.

Carts with a rider, or minecarts with chests, have more momentum and so climb higher than carts that are unloaded. With a rider, a minecart can climb at least 24 blocks before needing powered rails to go higher.

=== Mob behavior ===
{{exclusive|java|section=yes}}
{{IN|java}}, most mobs avoid walking on rails,<ref>{{bug|MC-33359||Mobs are unable to cross minecart rails|WAI}}</ref> but they ignore rails when they are already on them. Jumping mobs like [[slime]]s, [[frog]]s<ref>{{bug|MC-263494||Frogs jump over rails and sometimes land on them|WAI}}</ref>, and [[goat]]s can jump onto rails, but frogs and goats do not walk onto rails. [[Aquatic]] creatures like [[guardian]]s, [[tadpole]]s, and [[fish]] that flop around on land can flop onto rails. [[Parrot]]s can land on rails and [[endermen]] can teleport onto rails, although they do not walk onto them. In pursuit of their targets, zombies may push other mobs onto the rails in which case the mob on the rail ignores rails while on them. The only mobs that freely walk onto rails are [[spider]]s, [[cave spider]]s, and [[warden]]s.

== Sounds ==
{{Sound table/Block/Metal}}

== Data values ==
=== ID ===
{{edition|java}}:
{{ID table
|edition=java
|showblocktags=y
|showitemtags=y
|showforms=y
|generatetranslationkeys=y
|displayname=Rail
|spritetype=block
|nameid=rail
|blocktags=prevent_mob_spawning_inside, rails
|itemtags=rails
|foot=1}}

{{edition|bedrock}}:
{{ID table
|edition=bedrock
|shownumericids=y
|showforms=y
|generatetranslationkeys=y
|displayname=Rail
|spritetype=block
|nameid=rail
|id=66
|foot=1}}

=== Block states ===
{{see also|Block states}}

{{/BS}}

== Achievements ==
{{load achievements|On A Rail}}

== Video ==
<div style="text-align:center">{{yt|ILy1jrm_GUw}}</div>

== History ==
{{info needed section|initial waterlogged rail reveal}}
{{HistoryTable
|{{HistoryLine|java infdev}}
|{{HistoryLine||20100618|[[File:Rail (NS) JE1.png|32px]] [[File:Rail (EW) JE1.png|32px]] [[File:Rail (NE) JE1.png|32px]] [[File:Rail (ES) JE1.png|32px]] [[File:Rail (SW) JE1.png|32px]] [[File:Rail (NW) JE1.png|32px]] [[File:Rail (Ns) JE1.png|32px]] [[File:Rail (nS) JE1.png|32px]] [[File:Rail (Ew) JE1.png|32px]] [[File:Rail (eW) JE1.png|32px]] Added rails in the first [[Seecret Updates|"Seecret Friday Update"]] to Infdev.}}
|{{HistoryLine||unknown|Sloped rails are currently being dropped if the block on the side was destroyed.}}
|{{HistoryLine|java alpha}}
|{{HistoryLine||v1.2.0|dev=<nowiki>?</nowiki>|slink=:Category:Information needed requiring unarchived version|[[File:Rail (NS) JE2 BE1.png|32px]] [[File:Rail (EW) JE2 BE1.png|32px]] [[File:Rail (NE) JE2 BE1.png|32px]] [[File:Rail (ES) JE2 BE1.png|32px]] [[File:Rail (SW) JE2 BE1.png|32px]] [[File:Rail (NW) JE2 BE1.png|32px]] [[File:Rail (Ns) JE2 BE1.png|32px]] [[File:Rail (nS) JE2 BE1.png|32px]] [[File:Rail (Ew) JE2 BE1.png|32px]] [[File:Rail (eW) JE2 BE1.png|32px]] The textures of rails and curved rails have been changed slightly.}}
|{{HistoryLine|java beta}}
|{{HistoryLine||1.6|dev=Test Build 3|Before this update, parallel tracks would be used to create [[Tutorials/Minecart booster|minecart boosters]].}}
|{{HistoryLine||1.8|dev=Pre-release|Rails are now found in the new [[mineshaft]] chests.}}
|{{HistoryLine|java}}
|{{HistoryLine||1.0.0|dev=Beta 1.9 Prerelease|Rails are now destroyed by [[snowfall]] (bug).}}
|{{HistoryLine|||dev=Beta 1.9 Prerelease 4|Some rail behavior is now affected following the change of the south-west rule to [[south-east rule]].}}
|{{HistoryLine|||dev=Beta 1.9 Prerelease 6|Rails are now broken faster using a [[pickaxe]].}}
|{{HistoryLine||1.3.1|dev=12w25a|Rails can now be placed on upside-down [[slab]]s and [[stairs]].}}
|{{HistoryLine||1.5|dev=13w04a|[[Mob]]s no longer walk over rails, if they are not currently standing on one.}}
|{{HistoryLine||1.8|dev=14w10a|Rails with [[Java Edition data values/Pre-flattening/Block IDs/Before 14w25a|numerical metadata variants]] 10 to 15, which are inaccessible through normal gameplay or even commands and as such require the use of external editors to exist, now have [[Missing model|no model]] [[File:Missing Model JE2.png|32px]]. Their appearances prior to this point used the south east curved rail model.}}
|{{HistoryLine|||dev=14w25a|Rails are now defined via [[block states]] rather than by numerical metadata. Prior to this version, the numerical metadata variants of the rail were as follows:
{{dvt|spritetype=block|sprite=rail|North-south}}
{{dvt|spritetype=block|sprite=rail|East-west}}
{{dvt|spritetype=block|sprite=rail|Accenting east}}
{{dvt|spritetype=block|sprite=rail|Ascending west}}
{{dvt|spritetype=block|sprite=rail|Ascending north}}
{{dvt|spritetype=block|sprite=rail|Ascending south}}
{{dvt|spritetype=block|sprite=rail|Curved south-east}}
{{dvt|spritetype=block|sprite=rail|Curved south-west}}
{{dvt|spritetype=block|sprite=rail|Curved north-west}}
{{dvt|spritetype=block|sprite=rail|Curved north-east}}
{{dvt|spritetype=block|sprite=missing-texture-block|dv=10-15|[[Java Edition removed blocks/Metadata variants#Boring variants|Inaccessible - behavior unknown]]|foot=1}}}}
|{{HistoryLine|||dev=14w26a|Rails with metadata values 10 to 15 have been completely removed from the game.}}
|{{HistoryLine||1.9|dev=15w44a|The average yield from [[chest minecarts]] in [[mineshaft]]s has been increased by more than 20 times. 
|Mobs no longer spawn on rails.}}
|{{HistoryLine||1.11|dev=16w32b|All sloped rail types' hitbox heights have been decreased from a full block to a half block.}}
|{{HistoryLine|||dev=16w39a|Rails now generate in [[woodland mansion]]s.}}
|{{HistoryLine||1.13|dev=17w47a|Prior to [[Java Edition 1.13/Flattening|''The Flattening'']], this block's numeral ID was 66.}}
|{{HistoryLine||1.14|dev=18w43a|[[File:Rail (NS) JE3 BE2.png|32px]] [[File:Rail (EW) JE3 BE2.png|32px]] [[File:Rail (NE) JE3 BE2.png|32px]] [[File:Rail (ES) JE3 BE2.png|32px]] [[File:Rail (SW) JE3 BE2.png|32px]] [[File:Rail (NW) JE3 BE2.png|32px]] [[File:Rail (Ns) JE3 BE2.png|32px]] [[File:Rail (nS) JE3 BE2.png|32px]] [[File:Rail (Ew) JE3 BE2.png|32px]] [[File:Rail (eW) JE3 BE2.png|32px]] The texture of rails has been changed.}}
|{{HistoryLine|||dev=19w12b|Rails can now be placed on [[glass]], [[ice]], [[glowstone]] and [[sea lantern]]s.}}
|{{HistoryLine||1.15|dev=19w39a|Placing a new, unconnected section of rails now orients them in the direction the [[player]] is facing, rather than always north-south.}}
|{{HistoryLine||1.17|dev=20w45a|All rail types can now be [[waterlogged]].
|Rails are no longer swept away by water.}}

|{{HistoryLine|pocket alpha}}
|{{HistoryLine||v0.8.0|dev=build 1|[[File:Rail (NS) JE2 BE1.png|32px]] Added rails.}}
|{{HistoryLine|||dev=build 2|Rails are now craftable.}}
|{{HistoryLine||v0.9.0|dev=build 1|Rails now generate in [[mineshaft]]s.}}
|{{HistoryLine||v0.14.0|dev=build 1|Rails can now be found in mineshaft [[chest]]s. }}
|{{HistoryLine|pocket}}
|{{HistoryLine||1.1.0|dev=alpha 1.1.0.0|Rails now generate in [[woodland mansion]]s.}}
|{{HistoryLine|bedrock}}
|{{HistoryLine||1.4.0|dev=beta 1.2.20.1|Rails can now be placed underwater.}}
|{{HistoryLine||1.10.0|dev=beta 1.10.0.3|[[File:Rail.png|32px]] The texture of rails has been changed.}}

|{{HistoryLine|console}}
|{{HistoryLine||xbox=TU1|xbone=CU1|ps3=1.00|psvita=1.00|ps4=1.00|wiiu=Patch 1|switch=1.0.1|[[File:Rail (NS) JE2 BE1.png|32px]] Added rails.}}
|{{HistoryLine||xbox=TU19|xbone=CU7|ps3=1.12|psvita=1.12|ps4=1.12|wiiu=Patch 1|switch=1.0.1|[[Mob]]s no longer walk over rails, if they are not currently standing on one.{{check version}}}}
|{{HistoryLine||xbox=TU46|xbone=CU36|ps3=1.38|psvita=1.38|ps4=1.38|wiiu=Patch 15|switch=1.0.1|Mobs no longer spawn on rails.}}
|{{HistoryLine||xbox=TU54|xbone=CU44|ps3=1.52|psvita=1.52|ps4=1.52|wiiu=Patch 24|switch=1.0.4|All sloped rail types' hitbox heights have been decreased from a full block to a half block.|Rails now generate in [[woodland mansion]]s.}}
|{{HistoryLine||xbox=none|xbone=none|ps3=none|psvita=none|ps4=1.90|wiiu=none|switch=none|[[File:Rail.png|32px]] The texture of rails has been changed.}}

|{{HistoryLine|new 3ds}}
|{{HistoryLine||0.1.0|[[File:Rail (NS) JE2 BE1.png|32px]] Added rails.}}
}}

== Issues ==
{{issue list}}

== Trivia ==
* When walking on a [[block]] that has a rail on top, the [[player]] hears the [[sound]] of the block they are walking on, but if they jump (while still walking), they hear the sound of [[iron]].<ref>{{bug|MC-1691||Sprinting / falling on level 1 and 2 snow, lily pads and carpet use the block below for the particles}}</ref>
* Rails are 750&nbsp;mm (approx. 2-foot 5-inch) narrow gauge (the gauge is the distance between the rails).
* A chest of rails has a total length of 64×27 = 1728 meters, which is slightly more than 1 mile (1.074 miles, 0.933 nautical miles).
* Rails do not touch the block they are placed on. The flat texture can actually be seen to hover over their supporting block.

== Gallery ==
=== Screenshots ===
<gallery>
Railtrack.png|An example of a track with curves and ramps.
Minecraftrollercoaster.jpg|An example of how to use the tracks as a roller coaster.
RailBug.png|A randomly generated misplaced rail found in a [[mineshaft]].
Floating rails.png|Three more floating rails in a mineshaft.
What the-- A Floating Rail?!.jpg|Even more floating rails.
Minecraft train.png|[[Villager]]s riding [[minecart]]s with rails below them.
Rail stop front.png|A railroad stop without any [[redstone]] switching mechanisms, based purely on the one-way curve intersection behavior.
sticky_piston_rails.gif|An example of sticky piston use with rails.
Beta Roller Coaster.png|A roller coaster.
</gallery>

== See also ==
* [[Powered rail]]
* [[Activator rail]]
* [[Detector rail]]

== References ==
{{reflist}}

== Navigation ==
{{Navbox redstone|components}}
{{Navbox blocks|Utility}}

[[Category:Non-solid blocks]]
[[Category:Mechanisms]]
[[Category:Manufactured blocks]]
[[Category:Generated structure blocks]]

[[cs:Kolej]]
[[de:Schiene]]
[[es:Raíl]]
[[fr:Rails]]
[[hu:Sín]]
[[it:Binario]]
[[ja:レール]]
[[ko:레일]]
[[lzh:鐵軌]]
[[nl:Spoor]]
[[pl:Tory]]
[[pt:Trilho]]
[[ru:Рельсы]]
[[uk:Рейки]]
[[zh:铁轨]]
