You could try using imessage-exporter. I haven't used it myself but have seen it being recommended before in this sub.
Data Hoarder
We are digital librarians. Among us are represented the various reasons to keep data -- legal requirements, competitive requirements, uncertainty of permanence of cloud services, distaste for transmitting your data externally (e.g. government or corporate espionage), cultural and familial archivists, internet collapse preppers, and people who do it themselves so they're sure it's done right. Everyone has their reasons for curating the data they have decided to keep (either forever or For A Damn Long Time (tm) ). Along the way we have sought out like-minded individuals to exchange strategies, war stories, and cautionary tales of failures.
thanks will check on this as well.
Thanks for sharing!
As I recall, if you have a MacBook, iMessage syncs your messages and stores them in a file named ~/Library/Application Support/MobileSync/Backup
That file or files (my notes don't say number or the names of files) is just a SQL database which can be queried with the sqlite client, or exported into a more friendly format.
This solution worked for me about 5 years ago; I don't know if Apple still allows this.
Do you know if this includes attachments as well? Or are they stored elsewhere.
Unfortunately I don't remember.
IIRC there's some EU regulation that is going to mandate iMessage to be compatible with Android, which means Apple may soon make iMessage more open, and more options should appear in a few years.