Authorities found five bodies with gunshot wounds - a boy and girl under 10 years old, two adult men and a young woman or teenager.
A toddler later died at the hospital. Another woman was in critical condition, Lt. Phil Cooke said.
"It looks like it was family on family, murder suicide and that all the people were connected," Cooke said. He said police were still trying "to get some indication why this happened."
One of the adults, a man, died of an apparent self-inflicted gunshot wound, Cooke said.
A neighbor called police at about 8:30 p.m. Sunday to report that a woman was injured outside the townhome, located in the Santa Clara community of Rivermark, about 7 miles northwest of San Jose,
Cooke said two handguns were found at the scene.
The lieutenant said investigators were working to notify relatives and confirm identities before releasing names.
Residents describe the community of Rivermark as relatively quiet. The area has a mix of townhouses and larger homes with manicured lawns, shopping centers and restaurants.
"It's the sleepiest little area. Nothing ever happens here," said Jackie Stewart, who walked with her husband from her nearby home to see the crime scene.
Cooke said he could recall three other family shootings in the last several years in Santa Clara, a city of about 108,000. And in November, authorities said, a Silicon Valley engineer opened fire at an office park hours after being fired from his job, killing three colleagues.