Two boys who were accused of raping a six-year-old girl at a school on Sydney's northern beaches have had their charges withdrawn, and have been awarded thousands of dollars in legal costs.

NSW Police were ordered to pay one boy $11,315 and the other $9746 during a hearing at Parramatta Children's Court on Tuesday.

In August last year, the boys, then aged 12, were arrested a Chatswood police station, and charged with several sex offences.

The Department of Education had alerted the State Crime Command's Child Abuse Squad about the alleged incidents.

Court documents had alleged the girl was attacked between June 24 and August 16. The alleged rapes and assaults occurred between 8am and 4pm, according to the documents.