To get from Rome to Pompeii you can go through Naples to which goes the train company Trenitalia for only 12.30 euros.
We bought round-trip tickets the day before at a machine like this in Termini Station:
You can also buy them at trenitalia.it
In the process of buying it is necessary to choose appropriate tickets – for trains leaving at different times – different price, but the time is not indicated on the ticket itself, and all the locals, with whom we clarified this issue, said that we could go on any flight on that day – it is unclear, but just in case we went at our time. Also, make sure that the trip will be without transfers – the first time you may not be able to figure it out.
Before boarding the train, we punch our tickets in a special punching machine on the platform and we’re good to go.
The trip to Naples takes about 3 hours, but there are faster and more expensive options.
From Naples to Pompeii there is a suburban narrow-gauge train called Circumvesuviana. It departs from the Napoli Garibaldi stop, which can be reached by crossing the road from the entrance of the Napoli Centrale station, where the train arrives from Rome and then following the underpasses according to the signs.
We were unlucky, there was a strike on the Circumvesuviana, But a cab driver showed up near the ticket office, gathering people who needed to go to Pompeii in the car, which would be cheaper, and we took advantage of it.