The route
SJ runs direct trains from Stockholm Central to Oslo Central Station, heading west across central Sweden to Karlstad on Lake Vänern, then through Arvika and over the border to Kongsvinger and Oslo. The trip takes about 5.5 to 6.5 hours. You can compare departures and book Stockholm–Oslo tickets on Omio.
Engineering works sometimes replace parts of the route with buses, especially in summer, so check the timetable for your date.
Alternatives
Long-distance coaches take around 7.5 to 8 hours and are often the cheapest choice. Flights take about an hour, plus airport transfers. From Oslo, Norway's railways continue to Bergen and Trondheim; see NorwayMaps for the Norwegian network.
Border crossing
Sweden and Norway are both in the Schengen area, but spot checks happen, so carry a passport or national ID card.