Can't restore my notes on macOS My Mac was updated to Sierra and, although I can use the Notes app just fine, it erased all my previous notes and I don't have a backup in Time Machine or iCloud.
I tried to recover them from the library and changed the extension to .html (for example: NotesV2.storedata-wal.html) but when I open it in a browser it just code garbage.
How can I get my notes back?
It might be possible to recover the text of your notes. I cannot gaurantee this will work for you, but I've tried this in High Sierra and it worked for me. There might be an easier way, I'm not sure.

Using Finder or Terminal check in the following directory (Note - this may well be a different directory from the one you tried first)

~/Library/Group Containers/group.com.apple.notes


for the following file

NoteStore.sqlite


(In Finder, select  Go->Go to Folder, enter ~/Library/  , then navigate to the dir shown above)

If this file exists, copy it to your Desktop. (Otherwise, sorry, game over, although someone else might know otherwise)

You will now need mac_apt (macOS Artifact Parsing Tool) to analyse this file.

Download a compiled bundle of mac_apt for macOS from 

https://github.com/ydkhatri/mac_apt/releases

I had to use the 10.13 bundle on High Sierra.

Using terminal, then cd into the mac_apt directory you have downloaded.

cd ~/Downloads/&lt;name of mac_apt directory&gt;


You should see the following two files:-

mac_apt_singleplugin.app
mac_apt.app


Now you need to run mac_apt_singleplugin.app to analyse your Notes sql notes db

In terminal, run the following in the mac_apt download directory

./mac_apt_singleplugin.app/Contents/MacOS/mac_apt_singleplugin -i ~/Desktop/NoteStore.sqlite -o ~/Desktop/NotesOutput NOTES


This should create ~/Desktop/NotesOutput

Inside this directory will be a log .txt file, and if you are lucky, a Notes.csv file. The csv file can be opened in any spreadsheet e.g. Numbers, and you can search through its fields to find the text of your notes if they were in the original file. You can copy / paste these into text files. Alternatively it might well be possible to run a script to pull out particular csv fields into individual text files - someone here may be able to help you with that particular problem.