Reason JWT decode


Hi :wave:

is there already a library for Reason (Bucklescript) to handle JWTs?
I googled around and only found Ocaml libs (

What I really want to achieve is to decode the payload in the token (client side).
Is this even possible at all? Because the decoder wouldn’t know the types of the decoded payload, right?

Thank you for your help!



I have recently developed a pretty comprehensive library for JOSE, which among other things includes JWT. Sadly (in this case) it’s for native so won’t work in bucklescript, but I have done insights.

If you just want to decode the payload you can just split the string on . and then take the middle part and base64url decode it. That will give you a JSON string that you can parse with bs-json.
If you want to validate the JWT I’m not sure how to do that in a JS environment and it also depends on what algorithm is used.


Just a quick tip – JWTs actually use base64url, not base64. There are a couple of slight differences which caused me big problems at work last week! Using atob for JWT payloads is unsafe.