In 41 states, people accused or convicted of crimes have the legal right to rewrite history. They can have their criminal records expunged, and in theory that means that all traces of their encounters with the justice system will disappear.

But enormous commercial databases are fast undoing the societal bargain of expungement, one that used to give people who had committed minor crimes a clean slate and a fresh start.

Most states seal at least some records of juvenile offenses. Many states also allow adults arrested for or convicted of minor crimes like possessing marijuana, shoplifting or disorderly conduct to ask a judge, sometimes after a certain amount of time has passed without further trouble, to expunge their records. If the judge agrees, the records are destroyed or sealed.

But real expungement is becoming significantly harder to accomplish in the electronic age. Records once held only in paper form by law enforcement agencies, courts and corrections departments are now routinely digitized and sold in bulk to the private sector. Some commercial databases now contain more than 100 million criminal records. They are updated only fitfully, and expunged records now often turn up in criminal background checks ordered by employers and landlords.