Robert E Crimo III, 22, was detained after a brief chase, police said.
The gunman climbed on to a roof, shooting randomly at spectators using a high-powered rifle.
It is the latest mass shooting to hit the US – there has been one in every week of 2022. President Joe Biden said he was “shocked” by the violence.
Hours later, two police officers were wounded in a shooting in Philadelphia during a Fourth of July fireworks display.
Mr Crimo was detained after a manhunt. He was referred to as a “person of interest” in Monday’s shooting, but after his arrest police said they believed he was responsible.
The gunman opened fire at the parade, near the city of Chicago, at around 10:15 local time (15:15 GMT), just a few minutes after it began.
The event was scheduled to include floats, marching bands, and community entertainment as part of the city’s Independence Day celebrations.
But what should have been one of the happiest days of the year quickly turned to panic, with pushchairs, purses and lawn chairs left discarded on the street as crowds fled from the scene. Some witnesses said they thought the sound of gunfire was fireworks.
The gunman fired at members of the public from the rooftop of a nearby shop, where police recovered “evidence of a firearm.”
Five adults were killed at the scene, as well as a further victim who the local coroner said died in a nearby hospital. At least two dozen others were injured.
One of those who died has been named as Nicolas Toledo, a man in his late 70s, who was only there because he requires full-time care and his family did not want to miss the event.
“We went to have a nice family day out – and then suddenly all this gunfire happens,” said Anand P, who was there during the parade.
“At the time I personally wanted to believe it was a car backfiring. Then people started running – so we start running.”
Another witness, Noel Hara, described how he was having breakfast at Starbucks after dropping off his son at the parade, when the chaos unfolded.
“About 30 people suddenly came rushing in screaming and we were locked into the Starbucks bathroom,” Mr Hara told the BBC.
“Moments later, they evacuated us from the Starbucks because they thought the shooter was trying to get in the back door.”
No charges have been filed against Mr Crimo and there is no indication of any motive.
Social media firms suspended accounts apparently belonging to Mr Crimo, who posted rap videos under an alias.
The attack in Highland Park comes just a month after deadly shootings in Uvalde, Texas and Buffalo, New York.
Illinois Governor Jay Robert Pritzker warned that mass shootings were becoming an “American tradition”.
“There are going to be people who are going to say that today is not the day, that now is not the time to talk about guns. I’m telling you there is no better day and no better time then right here and right now,” the Democratic governor said.
President Biden vowed to keep fighting “the epidemic of gun violence” in the country.
“I’m not going to give up,” he said, speaking outside the White House in Washington DC.
Last week, the president signed the first significant federal bill on gun safety in nearly 30 years.
It imposes tougher checks on young buyers and encourages states to remove guns from people considered a threat – but critics say the measures don’t go far enough.