Tools / Laravel APP_KEY Generator

Laravel APP_KEY Generator.

Generate a Laravel APP_KEY (base64:…) for AES-256-CBC or GCM, like php artisan key:generate, in your browser.

Runs in your browser

Must match 'cipher' in config/app.php (AES-256-CBC by default).

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result
.env line
APP_KEY
Additional keys
Details

About Laravel APP_KEY Generator

Laravel APP_KEY Generator creates the encryption key Laravel uses for encrypted cookies, sessions, the encrypt() helper and encrypted model casts, in exactly the format php artisan key:generate writes to .env: the prefix base64: followed by the Base64 encoding of 32 random bytes for AES-256 (or 16 bytes for AES-128). It is useful when you set up a server, container or CI pipeline where Artisan is not available yet, or when you need several keys at once, for example for different environments. The bytes come from your browser's cryptographic random number generator and the key never leaves the page: nothing is sent to a server, and the value is not stored in the address bar or history. Pick the cipher configured in config/app.php: AES-256-CBC is the default; the GCM variants are authenticated modes that Laravel also supports. Common mistakes: copying a key between environments so staging can decrypt production data, committing the .env file, generating a new key on an existing application (every encrypted cookie, session and encrypted column becomes unreadable), and forgetting to clear the config cache after changing it. To rotate safely in Laravel 11 and later, move the old value into APP_PREVIOUS_KEYS (comma-separated) and set the new one as APP_KEY, so existing data can still be decrypted while new data uses the new key.

How to Use

  1. Choose the cipher your application uses and how many keys you need.
  2. Copy the APP_KEY line into the .env file of one environment.
  3. Run php artisan config:clear (or config:cache) and restart workers.

Frequently Asked Questions

Is this the same as php artisan key:generate?

Yes. Artisan also writes base64: plus the Base64 encoding of random bytes of the cipher's key length (32 bytes for AES-256, 16 for AES-128).

Is it safe to generate a key in the browser?

The key is created with the Web Crypto random number generator on your device and is never sent or stored by this site. For maximum caution, generate production keys on the server with Artisan.

What happens if I change APP_KEY on a live app?

Encrypted cookies, sessions and values encrypted with the old key can no longer be decrypted. Put the old key in APP_PREVIOUS_KEYS to keep reading them during rotation.

Does APP_KEY hash passwords?

No. Passwords are hashed with bcrypt or Argon2, which do not use APP_KEY, so changing it does not log users out of their passwords.

Related Tools