JavaScript encryption libraries

Updated Nov 2026

JavaScript encryption libraries encrypt and decrypt data with keys in browsers and Node.js. Authenticated encryption adds a tag that makes decryption fail when the ciphertext has changed. These libraries protect the tokens, messages, and stored records that apps exchange or keep on behalf of users.

Popularity

jose has the most monthly downloads in this comparison, at 878.5M.

LibraryMonthly downloadsStarsLast releaseLicense
jose
878.5M
7.9KNov 2026MIT
noble-ciphers
220.7M
437Aug 2026MIT
Forge
211.3M
5.4KNov 2026(BSD-3-Clause OR GPL-2.0)
TweetNaCl.js
195.3M
1.9KFeb 2020Unlicense
CryptoJS
102.5M
16.4KOct 2023MIT
eciesjs
64.0M
162Apr 2026MIT
crypto-browserify
53.6M
683Oct 2024MIT
libsodium.js
28.8M
1.2KApr 2026ISC
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Signs, verifies, encrypts, and decrypts JSON Web Tokens and other JOSE formats across Node.js, browsers, and edge runtimes.

Downloads / mo
878.5M
Stars
7.9K
Last release
6.2.17
License
MIT

Strengths

  • Encrypts JSON Web Tokens. jwtDecrypt decrypts a token and validates its claims set.
  • No dependencies. The package has no dependencies and exports tree-shakeable ES modules.

Quickstart

From EncryptJWT.md
$ npm install jose
import { EncryptJWT, generateSecret } from 'jose';

const secret = await generateSecret('A256GCM');
const token = await new EncryptJWT({ sub: 'example' })
  .setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })
  .encrypt(secret);

jose examples

From open-source projects on GitHub

Provides symmetric ciphers with authenticated-encryption variants for JavaScript.

Downloads / mo
220.7M
Stars
437
Last release
2.4.0
License
MIT

Strengths

  • Manages nonce prefixes. Use managedNonce to prepend a generated nonce to ciphertext.
  • Detects changes during authenticated decryption. Choose an AEAD variant whose decrypt method checks its authentication tag.

Limitations

  • Passwords need separate key derivation. Derive a password key with an additional KDF package before encrypting.
  • New messages need fresh nonces. Do not reuse a nonce with the same key.

Quickstart

From README.md
$ npm install @noble/ciphers
import { gcm } from '@noble/ciphers/aes.js';
import { randomBytes } from '@noble/ciphers/utils.js';

const key = randomBytes(32);
const nonce = randomBytes(12);
const ciphertext = gcm(key, nonce).encrypt(new TextEncoder().encode('hello'));

noble-ciphers examples

From open-source projects on GitHub

Provides block-cipher encryption and decryption APIs.

Downloads / mo
211.3M
Stars
5.4K
Last release
1.4.3
License
(BSD-3-Clause OR GPL-2.0)

Strengths

  • Checks authenticated decryption results. Check decipher.finish before using decrypted GCM output.
  • Includes password-based key derivation. Use pkcs5.pbkdf2 to derive a key from a password.

Limitations

  • Synchronous key generation blocks execution. Choose asynchronous RSA key generation for interactive applications.

Quickstart

From README.md
$ npm install node-forge
import forge from 'node-forge';

const key = forge.random.getBytesSync(32);
const iv = forge.random.getBytesSync(12);
const cipher = forge.cipher.createCipher('AES-GCM', key);
cipher.start({ iv });
cipher.update(forge.util.createBuffer('hello', 'utf8'));
cipher.finish();
const ciphertext = cipher.output.getBytes();
const tag = cipher.mode.tag.getBytes();

Forge examples

From open-source projects on GitHub

Provides a JavaScript implementation of NaCl for browsers and Node.js.

Downloads / mo
195.3M
Stars
1.9K
Last release
1.0.3
License
Unlicense

Strengths

  • Combines peer keys with encryption. Use box with the recipient’s public key and sender’s secret key.
  • Returns null on authentication failure. Check the open result before decoding the plaintext.

Limitations

  • Text needs explicit byte encoding. Encode strings and serialize objects before encryption.
  • Shared Buffer views need copying. Use Buffer.from(array) to avoid sharing a returned subarray’s backing buffer.

Quickstart

From README.md
$ npm install tweetnacl
import nacl from 'tweetnacl';

const key = nacl.randomBytes(nacl.secretbox.keyLength);
const nonce = nacl.randomBytes(nacl.secretbox.nonceLength);
const message = new TextEncoder().encode('hello');
const ciphertext = nacl.secretbox(message, nonce, key);

TweetNaCl.js examples

From open-source projects on GitHub

Implements crypto standards such as AES, SHA hashes, and HMAC in JavaScript.

Downloads / mo
102.5M
Stars
16.4K
Last release
4.2.0
License
MIT

Limitations

  • No longer maintained. The maintainers recommend the native crypto module in Node.js and current browsers.

Quickstart

From README.md
$ npm install crypto-js
var CryptoJS = require('crypto-js');

var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();

CryptoJS examples

From open-source projects on GitHub

Encrypts data to an elliptic curve public key with the ECIES hybrid scheme.

Downloads / mo
64.0M
Stars
162
Last release
0.5.0
License
MIT

Strengths

  • Runs on many platforms. The same API runs in browsers, Node.js, Bun, Deno, and React Native.
  • Uses audited dependencies. Its cryptography comes from node:crypto and the audited noble packages.

Limitations

  • Settings must match across apps. Use the same curve, cipher, and nonce settings on every side of the exchange.

Quickstart

From README.md
$ npm install eciesjs
import { PrivateKey, decrypt, encrypt } from "eciesjs";

const encoder = new TextEncoder();
const decoder = new TextDecoder();

const sk = new PrivateKey();
const data = encoder.encode("hello world🌍");
const decrypted = decrypt(sk.secret, encrypt(sk.publicKey.toBytes(), data));
console.log(decoder.decode(decrypted));

eciesjs examples

From open-source projects on GitHub

crypto-browserify

Reimplements the Node.js crypto module in plain JavaScript for the browser.

Downloads / mo
53.6M
Stars
683
Last release
3.12.1
License
MIT

Limitations

  • Covers a subset of Node.js crypto. Check the implemented list before porting code that calls other crypto functions.

Quickstart

From index.js
$ npm install crypto-browserify
const crypto = require('crypto-browserify');
const { Buffer } = require('buffer');

const key = crypto.randomBytes(32);
const iv = crypto.randomBytes(12);
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
const ciphertext = Buffer.concat([cipher.update('hello', 'utf8'), cipher.final()]);
const tag = cipher.getAuthTag();

crypto-browserify examples

From open-source projects on GitHub

libsodium.js

Provides JavaScript and WebAssembly wrappers for libsodium cryptographic operations.

Downloads / mo
28.8M
Stars
1.2K
Last release
0.8.4
License
ISC

Strengths

  • Processes ordered encrypted message streams. Use secretstream to encrypt messages and mark the final chunk.
  • Converts string inputs automatically. String input is converted into UTF-8 bytes for binary APIs.

Limitations

  • Initialization is asynchronous. Await sodium.ready before calling cryptographic functions.
  • Password hashing needs sumo. Use the sumo package for crypto_pwhash functions.

Quickstart

From README.md
$ npm install libsodium-wrappers
import sodium from 'libsodium-wrappers';

await sodium.ready;
const key = sodium.randombytes_buf(sodium.crypto_secretbox_KEYBYTES);
const nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES);
const ciphertext = sodium.crypto_secretbox_easy('hello', nonce, key);

FAQ

CryptoJS is a JavaScript library of crypto standards such as AES and HMAC. Its maintainers have discontinued development and point to the native crypto module in Node.js and current browsers.

Forge implements network transports, ciphers, public key infrastructure, and message digests in JavaScript. It includes block ciphers such as AES and password-based key derivation.

jose implements JSON Object Signing and Encryption for JavaScript, including JWT, JWE, and JWK. It runs in Node.js, browsers, Cloudflare Workers, Deno, and Bun with no dependencies.

crypto-browserify reimplements the Node.js crypto module in plain JavaScript so that it can run in the browser.

TweetNaCl.js is a JavaScript port of the NaCl cryptographic library for browsers and Node.js. Its box function encrypts a message for a recipient's public key.

Await sodium.ready before using its cryptographic functions and constants.

For coding agents

Found your encryption library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official