A remorseful rapper who boasted online about deadly gang violence on Dallas streets will now take the rap for his social media posts that prosecutors said mirrored real-life violence.

Nykees Earl Campbell, the 20-year-old leader of the YNB Stretch Gang in south Dallas, was sentenced to 12 years in federal prison on Wednesday after pleading guilty to distributing cocaine in February. Campbell initially faced nearly six years behind bars, but a judge approved a prosecutor’s request for an enhanced sentence due to Campbell’s alleged gang activities, the Dallas Morning News reports.

Campbell wasn’t charged in an ambush robbery during which he allegedly shot a man eight times as he slept, but he remains a suspect in that crime and other alleged gang violence that he later gloated about in YouTube and Facebook Live videos.

District Judge Barbara Mynn told Campbell — who has no prior criminal convictions — that her decision relied heavily on words that “came out of your mouth” and provided a glimpse into his thinking process.

“You’re bragging about shooting a person,” Lynn told Campbell. “It’s violence times 10 at every phase.”

A police detective in Dallas testified Wednesday that Campbell — known on the streets as “NaNa” or “Ny-Nizzle” — remains a suspect in several murders, along with several other suspected YNB gang members.

After Campbell’s arrest in November, the gang’s string of violent crimes stopped immediately, Detective Eric Barnes testified. In all, 13 people with alleged ties to the gang were also charged with drug and gun offenses. Some of those charged have already been sentenced, the Morning News reports.

A deadly street war between the YNB and the Ben Frank Gang — or BFG — started when a BFG member threatened to kidnap Campbell’s now-3-year-old daughter, Barnes said.

That prompted Campbell to retaliate with threats of his own to the rival gang.

“He’s adamant that he raps about stuff he lives,” Barnes said.

The YNB even threatened singer Chris Brown over an unspecified “beef,” Barnes said, and warned him not to come to Dallas.

Assistant US Attorney Rick Calvert said Campbell sparked a “ridiculous amount of violence” with his videos, including several shootings. Campbell also boasted about shooting a man eight times while stealing drugs and jewelry in June 2016 and police believe he was the gunman, Barnes said.

Police in Dallas started eyeing the gang in early 2016 after a double murder of rival BFG gangsters that remains unsolved. But Barnes said a 19-year-old YNB member recently sentenced to 40 years in prison for another robbery is the suspected gunman.

To escalate the gang war, Barnes said YNB produced a video at the exact location of the double murder and used lyrics to reference the killings. The gang even posted a photo of a YNB member in front of the home of one of the victims, complete with a caption that it was now a “haunted house,” Barnes said.

“This organization was out of control,” the detective testified.

Campbell’s attorney, Dianne Jones McVay, said her client was guilty of “rapping” and nothing else.

“They can’t prove their murders … but they want to blame my client for all of them,” McVay said.

For his part, Campbell took a more conciliatory tone when addressing the judge, promising to be a “better man” while apologizing for his mistakes.

“I was really just caught up in that,” Campbell said of the videos. “I’m not saying it’s right.”