AES Key Generator

Generate strong random AES keys (256, 192 or 128 bits) in hex, Base64 or JWK, with a matching IV — created in your browser.

● 🔒 Your data is processed locally in your browser with the Web Crypto API and is never uploaded to our servers.

How to generate an AES key

  1. Choose the key size: 256 bits is recommended.
  2. Choose the format your code or configuration expects: hex, Base64, Base64URL or JWK (JSON Web Key).
  3. Choose the IV (initialization vector) size for your mode: 12 bytes for AES-GCM, 16 bytes for AES-CBC or CTR.
  4. Click Generate new key and copy the key and the IV.

The key is produced by your browser's Web Crypto API (crypto.subtle.generateKey), which uses your operating system's cryptographic random generator. It is never sent to a server.

AES key sizes and lengths

KeyBytesHex charactersBase64 charactersBase64URL
AES-12816322422
AES-19224483232
AES-25632644443

So an AES-256 key is 32 bytes: 64 characters in hex or 44 in Base64. If a library asks for a “32-character key”, it usually means 32 bytes, not a 32-character password. All three sizes are secure; AES-256 adds a margin for long-term data and is the common default.

Generate an AES key in code

Tool256-bit key
OpenSSL (Linux, macOS)openssl rand -hex 32 or openssl rand -base64 32
Linux shellhead -c 32 /dev/urandom | base64
Pythonsecrets.token_bytes(32) or secrets.token_hex(32)
Node.jscrypto.randomBytes(32).toString("hex")
JavaKeyGenerator kg = KeyGenerator.getInstance("AES"); kg.init(256);
C#using var aes = Aes.Create(); aes.KeySize = 256; aes.GenerateKey();

Keys and IVs: the rules

FAQ

Is it safe to generate an AES key online?

Here, yes: the key is generated in your browser with the operating system's secure random generator, and it never leaves your device. For production secrets, you can also run one of the commands above on your server.

Which format should I choose?

Hex is the easiest to read and paste in config files; Base64 is shorter; Base64URL is safe in URLs and JSON; JWK is the format of the Web Crypto API and JOSE libraries.

Can I test the key right away?

Yes: use it with AES-GCM Encrypt, then decrypt with AES-GCM Decrypt.

Is AES-128 still secure?

Yes. No practical attack breaks AES-128; AES-256 is chosen for an extra margin (for example against future quantum computers) and because many standards require it.

I need random bytes for something else.

Use the Random Bytes Generator or the Secure Token Generator for API tokens.