JavaScript bookmark to check contexts in console


Validating contexts (cx) or unstructured data (px) parameters in your browser network tab currently takes three steps:

  1. Copy the BAS64 string
  2. Decode the BASE64 (e.g. through a decoding website)
  3. Beautify the JSON data to make it more readable.

For our team, I’ve created a JavaScript bookmark that does this automatically:

  1. Copy the BASE64 sting
  2. Hit the bookmark and fill out the string.
  3. The JSON object is pretty-printed in your console.

Here’s the code you can set as the URL in your bookmark

javascript:(function()%7Bvar input %3D prompt('Snowplow base64 input')%3Binput %3D atob(input)%3Bconsole.log(JSON.stringify(JSON.parse(input)%2C null%2C 2))%7D)()

I hope it can help some of you out.


On a Mac, pbpaste | base64 -D | json_pp works too :slight_smile:

If you’re using Google Chrome our Snowplow Chrome inspector will also do this for you (both the decoding and the indented formatting).