# How to encode JSON in the browser

**URL:** <https://community.auth0.com/t/how-to-encode-json-in-the-browser/7437>\
**Category:** Get Help\
**Tags:** jwt, client-setup\
**Created:** [July 10, 2017, 1:42pm UTC](https://community.auth0.com/t/how-to-encode-json-in-the-browser/7437 "2017-07-10T13:42:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![milpas999](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@milpas999](https://community.auth0.com/u/milpas999)\
**Post date:** [July 10, 2017, 1:42pm UTC](https://community.auth0.com/t/how-to-encode-json-in-the-browser/7437/1 "2017-07-10T13:42:24Z")

</div>

I just want to encode some information from the browser and send it over to the nodejs server.

I am able to encrypt and decrypt the JWT using jsonwebtoken NPM.

But i wanted to encrypt the data from client side i.e from the browser and send it over to the server.

Is there any way to use jsonwebtoken NPM from the browser.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [July 11, 2017, 3:30pm UTC](https://community.auth0.com/t/how-to-encode-json-in-the-browser/7437/2 "2017-07-11T15:30:07Z")

</div>

There’s a couple of things worth noting here, the `jsonwebtoken` library supports signed JWT tokens, but it has no support for encryption/decryption. This would mean the data in the JWT would not be encrypted so from that perspective the library would not be useful.

Signing a JWT token in the browser would also be irrelevant because the signing key would need to be available to the browser, which would mean available to everyone that was also interested in obtaining it. This means using that library in the browser would not get you anything.

If you want to protect the data in-transit from the browser to the server then you should ensure you’re using HTTPS; this would mean the data (all of it) would indeed be encrypted when sent from the browser to the server.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:55am UTC](https://community.auth0.com/t/how-to-encode-json-in-the-browser/7437/3 "2018-03-02T05:55:14Z")

</div>


