Most visitors choose to get from Hanoi to Sapa by overnight train; it's more comfortable and safer than a bus or motorbike, and a lot cheaper than hiring a car.
Three sleeper trains leave Hanoi's train station each evening, at 20:35, 21:10 and 21:50. The SP1, SP2, SP3 and SP4 mainly comprise privately run sleeper cabins and the SP7 and SP8 also have soft seats. What can you expect on board? The privately operated soft-sleeper cabins are generally clean and comfortable and certainly adequate for the length of journey. Each air-conditioned cabin contains four berths, two upper and two lower. Doors are lockable but it's still advisable to keep valuables on your person, or sleep with them under your pillow, particularly if you don't know your cabin mates.
Hard sleepers are adequate though a bit more crowded, with six berths in each cabin. Refreshments - including cold beer and crisps - are available on-board, though if you're fussy about your brand, or want to save a few dong, buy them in advance before you get to the station. Eat dinner first; places outside the station serve local dishes such as pho, or fill up on Western grub in Old Quarter. If you're looking for a cheaper option, or can't get onto one of the SP trains, the LC1 leaves Hanoi at 22:00 and the return LC2 departs at 18:45.
This takes around an hour longer and has no soft sleepers, but does have the option of hard seats for the hardcore traveller - having done it myself I really don't recommend it. The one daytime train, the LC3/LC4, departs at 06:10/09:15 and arrives more than 10 hours later. Although the overnight sleeper trains can be good fun, while also saving time and hotel bills, many people find it hard to get any decent rest on-board and therefore waste the next day catching up on sleep. Trains from Hanoi leave from station B, which is reached by crossing the tracks a few hundred metres north of the main station - onto Nguyen Khuyen - then turning left onto Tran Quy Cap.
Agents for the private carriages will provide you with a voucher for your journey, which you will need to exchange for a ticket at the operator's desk in the station.