Find deleted or missing iMessage messages (.ichat files) in ~/Library/Messages/Archive.
Attachments can be found in ~/Library/Messages/Attachments (view them all at ludicrous speed with Kenny Carruthers' Fileloupe).
Since .ichat files are in binary property list format, some text search tools may not work, but grep does just fine:
$ grep -R somekeyword ~/Library/Messages/Archive/*
Convert .ichat files to JSON with matrix-hacks' ichat2json. To handle multiple files, use a simple for loop like so:
$ for i in *; do ichat2json "$i" > "$i.txt"; done
.ichat files can be converted to XML via plutil as explained by Sean Moubry:
$ plutil -convert xml1 message.ichat.
plutil reportedly supports conversion to JSON as well, but not in my brief testing:
$ plutil -convert json message.ichat
invalid object in plist for destination format
UPDATES:
imessage-exporter: "Export macOS iMessage data + run iMessage Diagnostics"
/mac | Jul 17, 2017