I want to export a few items from my localStorage to save it externally but in a format so that I can import it again later.
My attempt was to write executable code that
Just a modernized version of @iceLord answer.
Just run this in the console, it will put the code to restore the localStorage back into your clipboard.
copy(`Object.entries(${JSON.stringify(localStorage)})
.forEach(([k,v])=>localStorage.setItem(k,v))`)
Bookmarklet version
javascript:prompt(`localStorage from ${location.host}${new Date().toLocaleString()}`, `/* localStorage from ${location.host}${new Date().toLocaleString()}*/Object.entries( ${JSON.stringify(localStorage)}).forEach(([k,v])=>localStorage.setItem(k,v))`)