Railroads are getting more efficient, and their customers are paying for it.

Large railroads such as Norfolk Southern Corp. and Union Pacific Corp. are moving quickly to streamline their operations, switching to fewer, longer trains that run on tighter schedules.

But shippers ranging from pasta giant Barilla America Inc. to small lumber distributors...