The victim of a bloody subway attack told The Post he thought he was “not coming out alive” when his attacker pulled out a 6-inch kitchen knife during the assault.

“He tried to stab me over and over,” said Roberto Hernandez, 39, who was riding a northbound D train at 1:45 a.m. Saturday when a group of five tried to rob him of his cash then turned violent. “It bled so much I couldn’t see.”

Hernandez, a restaurant cook in Bushwick, had a 12-inch slice to his left arm, staples in his head and stitches over a gash in his chest when The Post visited him at his Borough Park home Monday.

He told a Post reporter he had $20, his cellphone and a pair of Beats brand headphones with him when the brutes demanded his cash — but he refused.

“If I gave them the money, next they say give us the phone, give us the Beats!”

When Hernandez pushed back, two of his assailants started punching him — and then one pulled out a 6-inch blade, he said.

“I think, ‘I’m going to die in that car,’” he said.

The would-be thief stabbed Hernandez in the head and torso, and the group then fled the train at Grand Street.

“After they got off … I couldn’t believe it happened. I think, ‘I’m not coming out of this alive.’”

Hernandez said several bystanders on the train witnessed the violent gang-up, but nobody stepped in.

“There were a couple of people on the train and they didn’t do nothing! Not even call the police,” he told fumed.

He added that he’s been watching his back since the bloody brawl.

“Today I went to the store, I was looking behind me the whole time,” he said. “I don’t feel comfortable getting on the train.”

Early Monday morning a 21-year-old was stabbed by a group of men inside an Upper West Side subway station in a similar attack, although police don’t believe the two are related.