Gloire Pongo pulled out the machete on a train in January.
Gloire Pongo pulled out the weapon on a Greater Anglia service in Essex on Sunday, 20 January.
The 25-year-old, of Guildford Road, was detained by police after they intercepted the train in Witham.
No one was injured during the incident.
At court, Pongo pleaded guilty to possessing a bladed article in a public place.
As well as the nine-month prison sentence, he was ordered to pay a £140 victim surcharge.
Inspector Mark Hook from British Transport Police, said: “This is a frightening weapon and I am really pleased we were able to intercept the train and arrest Pongo quickly. He is now rightfully behind bars.
“This case exemplifies the strength of our relationship with the rail industry. Together, we reacted quickly to a report of a man in possession of a knife, we identified the train and met it, later detaining a man with no harm coming to passengers.
“We’ll continue to work closely with all our rail industry partners to drive out knife crime, and send a very clear message that possessing these potentially deadly weapons will not be tolerated.”