Updated:

Rail: item ID and commands

The ID for Rail is minecraft:rail. It is a placeable block, so the same ID works in /give, /setblock and /fill. The ID has been the same since Java 1.13.

Basic data

NameRail
ID (Java Edition)minecraft:rail
TypeBlock (also an item)
Java versionsJava 1.13 to 26.3
Bedrock 26.52Same ID works (tested on a server)
Stack size64
Hardness0.7
Blast resistance0.7
Best toolPickaxe

Commands you can copy

Java Edition

Give one

/give @p minecraft:rail 1

Give a full stack (64)

/give @p minecraft:rail 64

Place at your feet

/setblock ~ ~ ~ minecraft:rail

Fill a 5×5 floor

/fill ~-2 ~-1 ~-2 ~2 ~-1 ~2 minecraft:rail

Remove from inventory

/clear @p minecraft:rail

Open this command in the Give generator

Bedrock Edition

Give one

/give @p rail 1

Give a full stack (64)

/give @p rail 64

Place at your feet

/setblock ~ ~ ~ rail

Remove from inventory

/clear @p rail

How to make it

Unlock the recipe

/recipe give @p minecraft:rail

Recipes come from the official Java 26.3 data. Some ingredients differ on Bedrock.

Block states

StateValuesDefault
shapenorth_south, east_west, ascending_east, ascending_west, ascending_north, ascending_south, south_east, south_west, north_west, north_eastnorth_south
waterloggedtrue, falsefalse

Place it with a state

/setblock ~ ~ ~ minecraft:rail[shape=east_west]

Bedrock uses different state names and syntax (for example ["facing_direction"=2]).

Version notes

This ID has not changed from Java 1.13 to the latest 26.3.

Java 1.20.5 and later write extra item data in [ ] (components); 1.20.4 and earlier use { } (NBT). A plain /give with only the ID is the same in both.

Questions

What is the ID for Rail?

It is minecraft:rail. In commands you can also write rail without minecraft:.

Why does the command turn red?

Check the spelling first. The Command Error Doctor can check it.

Related IDs