Skip to content

Instantly share code, notes, and snippets.

@kouks
Last active August 27, 2024 11:21
Show Gist options
  • Save kouks/3a5f83f26343d209d58364946e336bbc to your computer and use it in GitHub Desktop.
Save kouks/3a5f83f26343d209d58364946e336bbc to your computer and use it in GitHub Desktop.
Encodes and/or decodes data as base64 url safe string.
// Encodes a js object as a url-safe base64 string.
encodeURIComponent(btoa(JSON.stringify({ ... })))
// Takes the previously generated string and returns a parsed js object.
JSON.parse(atob(decodeURIComponent('...')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment