Client-side text encryption/decryption libraries for JavaScript?

Looking for JavaScript crypto libraries for a personal project

I want to create a simple application that handles encryption and decryption of text data directly in the browser using JavaScript. The encrypted data will be saved to a server database, but the original plain text should never leave the client side.

Security doesn’t need to be military grade, but I’d prefer using a reliable algorithm that hasn’t been compromised yet.

What I’m hoping to achieve is something like:

var encoded = encryptText(plainText, password, secretKey);

For creating the encrypted version, and:

var decoded = decryptText(encoded, secretKey);

For getting back the original text.

I’ve already found one option but wondering what other good JavaScript encryption libraries are available for this kind of client-side work?

SJCL (Stanford JavaScript Crypto Library) is great for your needs. I built something similar last year, where I had to encrypt sensitive form data client-side before sending it. Their encrypt and decrypt methods are straightforward: input your password and plaintext, and it returns a JSON string containing everything necessary for decryption later. It takes care of salting and key derivation automatically, so you don’t have to deal with that. Just be cautious about weak passwords, as that could be your major vulnerability. SJCL won’t prevent you from using poor passwords, which would compromise your security. Stick with their convenient functions like sjcl.encrypt() unless you have a strong understanding of cryptography. While the documentation is lacking, once you grasp the basic usage, it’s a robust option.

Been there when building internal tools. Those crypto libraries work fine, but you’ll still need key management, secure storage, and backend integration.

Skip wrestling with crypto implementation details. Set up an automation workflow that handles the encryption pipeline instead.

Create a flow that takes plaintext, runs it through your preferred algorithm (AES, RSA, whatever), manages keys securely, and stores encrypted data where you need it. You get logging, error handling, and can add features like automatic key rotation later.

You don’t maintain the crypto code yourself. Just call your automation endpoint from JavaScript and let the workflow do the work.

Check out Latenode for this setup. Way cleaner than managing crypto libraries in the browser.

I’ve used several client-side crypto libraries. TweetNaCl-js is my top pick for what you’re doing. It’s a JavaScript port of NaCl with a clean API and solid security. Pretty straightforward to implement - just use secretbox for symmetric encryption since it handles encryption and authentication together. Web Crypto API is another good choice if you’re targeting modern browsers. No external dependencies since it’s built in, but the API’s more verbose than higher-level libraries. Performance is great though since it runs natively. One heads up on your approach - if you’re storing encrypted data server-side but only decrypting client-side, you need a solid key derivation strategy from passwords. PBKDF2 or scrypt work well to prevent rainbow table attacks on your password-derived keys.

hey! i totally agree, crypto-js is awesome! super user-friendly. also, check out SJCL if u want something simple but effective for encrypting on the client side. works like a charm!