While most tourists choose to fly, it's both possible and quite popular among locals to travel by train between Bangkok and Chiang Mai
Though to be honest, flying can be really just as cheap and much more convenient. I've flown between Chiang Mai and Bangkok round trip for $43US recently (I booked the ticket 1 month in advance through Skyscanner)
Schedule and prices: there are 5 daily departures leaving Bangkok for Chiang Mai that I'm aware of:
8:30am - 7:30pm: 641 baht (~$20US) for 2nd class seat
1:45pm - 4:05am next day: 391 baht (~$12US) for 2nd class seat (no AC) | 691 - 761 baht (~$20-23US) for 2nd class sleeper (has AC)
6:10pm - 7:15am next day: 941 - 1041 baht (~$28-31US) for 2nd class sleeper
7:35pm - 8:40am next day: 771 - 841 baht (~$23-25US) for 2nd class sleeper
10pm - 12:10pm next day: 431 baht (~$13US) for 2nd class seat (no AC), 531 - 581 baht (~$16-18US) for 2nd class sleeper (no AC)
You can check the latest schedule and fare on the official State Railway of Thailand site here
The site will ask you to create an account before booking; it's a simple process requiring your passport number and address
It accepts payment by Visa or MasterCard
Pay attention to the part of the website that tells you the particular class has AC or not. It's usually pretty hot and humid here in Thailand and not having AC can be rough
You should try to book in advance, especially if you want 1st class seats as there aren't a lot of those and they sell out weeks in advance. For 2nd class seats you should still try to book at least 1 week in advance
All of these trains depart from Bangkok'sHua Hamphong Railway Station. It's the main train station in Bangkok. For some reason the official site doesn't make this obvious
Try to get there 45-60 minutes in advance and your platform 15-20 minutes in advance
Just like the Grand Palace, there will be scammers in the area so ignore anyone outside the station who tells you anything (like you can't go in for whatever reason)
They arrive at the Chiang Mai Railway Station, which is a 60-80 baht Grab/taxi ride away from the old town or Nimman area
Condition of the train and amenities:
The trains are in decent shape. Nothing fancy. But I found it clean enough (at least in the sleeper class. I never took the seats)
The toilets are not the Asian squat style toilets
There's no wifi onboard (apparently 1st class does though) but there is power outlet in the 2nd and 1st class sleepers
They sell food onboard and the prices were actually pretty reasonable, ranging from 30-60 baht per item ($1-2US). Coffee was around 60 baht ($2US)
AC was actually quite strong. I had to wear a sweater to sleep comfortably