(a)
In any case in which a petition has been filed with a juvenile court to commence proceedings to adjudge a person a dependent child of the court, in any case in which a person is cited to appear before a probation officer or is taken before a probation officer pursuant to Section 307, or in any case in which a minor is taken before any officer of a law enforcement agency, the person or the county probation officer may, five years or more after the jurisdiction of the juvenile court has terminated as to the person, or, in a case in which no petition is filed, five years or more after the person was cited to appear before a probation officer or was taken before a probation officer pursuant to Section 307 or was taken before any officer of a law enforcement agency, or, in any case, at any time after the person has reached the age of 18 years, petition the court for sealing of the records, including records of arrest, relating to the person’s case, in the custody of the juvenile court and probation officer and any other agencies, including law enforcement agencies, and public officials as petitioner alleges, in his petition, to have custody of such records. The court shall notify the district attorney of the county and the county probation officer, if he is not the petitioner of the petition, and such district attorney or probation officer or any of their deputies or any other person having relevant evidence may testify at the hearing on the petition. If, after hearing, the court finds that since such termination of jurisdiction or action pursuant to Section 307, as the case may be, he has not been convicted of a felony or of any misdemeanor involving moral turpitude and that rehabilitation has been attained to the satisfaction of the court, it shall order sealed all records, papers, and exhibits in the person’s case in the custody of the juvenile court, including the juvenile court record, minute book entries, and entries on dockets, and other records relating to the case in the custody of such other agencies and officials as are named in the order. Thereafter, the proceedings in such case shall be deemed never to have occurred, and the person may properly reply accordingly to any inquiry about the events, records of which are ordered sealed. The court shall send a copy of the order to each agency and official named therein directing the agency to seal its records and five years thereafter to destroy the sealed records. Each such agency and official shall seal records in its custody as directed by the order, shall advise the court of its compliance, and thereupon shall seal the copy of the court’s order for sealing of records that it or he received. The person who is the subject of records sealed pursuant to this section may petition the superior court to permit inspection of the records by persons named in the petition, and the superior court may so order. Otherwise, except as provided in subdivision (b), such records shall not be open to inspection.
(b)
In any action or proceeding based upon defamation, a court, upon a showing of good cause, may order any records sealed under this section to be opened and admitted into evidence. The records shall be confidential and shall be available for inspection only by the court, jury, parties, counsel for the parties, and any other person who is authorized by the court to inspect them. Upon the judgment in the action or proceeding becoming final, the court shall order the records sealed.
(c)
Five years after a juvenile court record has been sealed, the court shall order the destruction of the sealed juvenile court record unless for good cause the court determines that the juvenile court record shall be retained. Any other agency in possession of sealed records shall destroy their records five years after the records were ordered sealed.