Generally, a free confession to police isn't automatically illegal, but its use in court is a complex matter. The vital factor is whether it was obtained fairly. Officers must adhere to specific rules, including https://panchanandshaw.com/blog/confession-before-police-is-it-valid/