Home / Secret Key Generators / Laravel
Laravel APP_KEY Generator
Generate a Laravel APP_KEY: a base64:-prefixed, base64-encoded 32-byte value, identical to what php artisan key:generate produces, entirely in your browser.
APP_KEY Generator
Or generate it on the command line
Laravel's own Artisan console command does exactly this, if you'd rather run it locally:
$ php artisan key:generate
Then in .env: APP_KEY=base64:YOUR_GENERATED_KEY_HERE. Restart your app (php artisan serve, your web server, and any queue workers) so the new key loads.
How this tool works
Laravel’s APP_KEY is the encryption key Laravel uses to encrypt and sign data such as cookies. This matches Laravel's own Encrypter::generateKey(): 32 random bytes (256 bits), base64-encoded, with a base64: prefix so Laravel's Encrypter class knows to decode it before use. That raw 32-byte key is what AES-256-CBC, Laravel's default cipher, requires. This tool generates the random bytes via the Web Crypto API's crypto.getRandomValues() in your browser, the same class of cryptographically secure source PHP's random_bytes() draws from on the server side.
- Laravel documentation, Encryption, laravel.com
- MDN Web Docs, Crypto: getRandomValues() method, developer.mozilla.org
I matched the APP_KEY format to Laravel's encryption documentation and generate the value locally with crypto.getRandomValues(). The page produces the base64-prefixed 32-byte key that Laravel's own key:generate command would. I recheck the Laravel docs when a new major version is released.
Frequently asked questions
What does Laravel's APP_KEY actually protect?
Anything passed through Laravel's encryption layer: encrypted cookies, signed URLs, queued job payloads, and any data your app explicitly encrypts. Laravel refuses to boot without a valid one.
Can I reuse the same APP_KEY across dev, staging, and production?
No. Each environment should have its own unique key. Reusing one key across environments means a leak in one place compromises encrypted data everywhere that key is used.
What happens if I change APP_KEY on an existing production app?
Anything already encrypted with the old key, existing sessions, encrypted database columns, becomes unreadable. Rotating APP_KEY on a live app needs a real migration plan, not a quick swap.