At some point I noticed how some notes are not properly synced. After further investigation, turns out, my notes haven’t properly synced in months, and my iPhone and my 2 Macs are completely out of sync.

But hey, Apple of course follows GDPR, and they offer a great way to export notes

To copy notes, open the Notes app on your Mac or at iCloud.com. Copy the text of each note and paste it into a document on your computer, such as a Pages or TextEdit document. Save the document to your computer.

The Notes app is AppleScriptable, but it only lets you access the HTML of the notes, not the attachments. Previously, people have accessed the Notes database directly using SQLite, but Krause says this is no longer possible due to encryption.

Notes also has a non-scriptable Export command that creates PDFs, but it can only be used on one note at a time.