Ù8One of the issues you need to be sure you want to pursue is the statement that you want to ride the trains. If for enjoyment (you love trains) or for environmental reasons, then yes, go for it.
But you are covering a lot of ground on this trip. Prague to Krakow is about 6 hours on the train, I think. I would have to compare departure and arrival times with the flight to decide which departs at a reasonable time, which gives me the most usable time on arrival and for the flight it may be the day of the week dependent. I suspect the train wins.
Krakow to Budapest is about 10 hours on the direct day train, but there is a night train. The night train isn’t cheap but it might be a fun experience. Of course it arrives at 7 am so then what do you do is sort of a question.
Budapest to Bucharest is a quick little 17 or 18 hours with a change or two. The trains aren’t up to the same standards as Western trains and they tend to run a bit late. Fly. If you wanted to do Brasov, it has become a large enough tourist hub that Wizair flies daily from Budapest in about 90 minutes and about 30€ and up for a ticket. Ive been twice and its nice and good for a day, maybe a day and an night. Bucharest is a better hub for departures back to the states or anyplace else in the world. So you could fly Budapest to Brasov and then Bucharest home.
If you have a somewhat more healthy budget than trains and discount airlines, then I would suggest that Prague to Krakow to Budapest makes for great major stops but rather than make the long haul trips you break it up with one or two night stops along the way. There are a crazy number of options. What I have done is I have gone to Daytrip.com and in this case I would put in Prague to Krakow then see what stops they offer. You may find a few that look to good to pass up and then you find the right bus and train to connect the dots and maybe spend a night in Olomouc for instance. Now you have two 3 hour train trips.
Now from Krakow to Budapest go through Slovakia. That’s going to take more work to figure out because the trains in Slovakia are not as easy. You might even choose a private transfer for a part of the trip. Slovakia is tough. So incredibly beautiful and so incredibly hard to get around. Strbske Pleso and the two Banska towns and even Kosice is nice. Bratislava … naaaaaa not so much. Oh, and the castles. They make the Germans jealous.
If you spend your time and money connecting the first three dots you can save Bucharest for another trip. If you are going to skip Slovakia then do look at the flights. Cheap and fast.
Day Trips and overnight trips in Hungary.
Eger and the Wine Country https://youtu.be/OUuA501Wpts?si=gdaTDVeULx2I7Xym
Szentendre for the Slavic village, arts and crafts
Esztergom for the Basilica
Visegrad for the castle on the hill
Pecs for the ottoman relics and the Zsolnay Ceramics
Lillafüred for the forest train and the lake and the castle https://youtu.be/qhuLmh_ils4?si=rb0KPEYp91-38IVf
Kecskemét for the cowboys and horses
Uzhhorod for the castle, culture https://youtu.be/UWucOJNcZ38?si=0rK6VFkSkPprOZOm