China and Taiwan have been ruled separately since 1949, but Beijing insists the island is part of its territory and has vowed to seize it one day.
There has been a series of spying cases in Taiwan, as China maintains military and political pressure on Taipei to accept its claims of sovereignty.
In the latest case, the four defendants were serving soldiers when they allegedly used their mobile phones to photograph military information, which was passed to "Chinese agents", the Taipei district prosecutors office said.
They received payments ranging from around NT$260,000 to NT$660,000 ($8,000-$20,000) "depending on the confidentiality level of the military information they provided", prosecutors said, without elaborating on the content.
The incidents happened from 2022 to 2024.
Three of the soldiers were discharged before an investigation was launched in August this year following a tip-off to the defence ministry.
The fourth soldier was suspended in August.
All four have been detained and charged with corruption and violating national security law for "leaking and delivering confidential information or electromagnetic records for China".
They face a maximum seven years in jail if convicted.
"The Chinese Communist Party's infiltration campaign against us has never stopped," the defence ministry said in a statement, describing the four accused as "treasonous and lawless".
"In order to actively prevent enemy espionage activities, the military will also continue its counter-intelligence education," it added.
In September, an ex-air force instructor was sentenced to 17 years in prison for "aiding the enemy" and delivering military secrets to China.