Laravel APP_KEY Generator

The same format php artisan key:generate writes: base64: followed by 32 random bytes.

APP_KEY

Generating in your browser…

Generated on your device with the Web Crypto API. Never sent or stored.

.env line
APP_KEY=

Prefer the terminal?

  • Artisan
    php artisan key:generate --show

How to use your Laravel APP_KEY

Copy the value above and add it to the APP_KEY line of your .env file, including the base64: prefix. Keep it out of source control: commit an .env.example with an empty value instead, and set the real value in your hosting provider's environment settings or a secrets manager.

Laravel's encrypter uses APP_KEY with AES-256-CBC, which needs exactly 32 bytes. The base64: prefix tells Laravel to decode the value before use. This is handy when you need a key for a container, CI job or server where you can't run artisan.

Is it safe to generate secrets in a browser?

Only if the secret is created locally, which is how this page works. The value comes from crypto.getRandomValues, the same cryptographically secure source browsers use for TLS keys, and it never leaves your device: there is no network request, log or analytics event that includes it.

If you prefer the command line, the commands on this page produce an equivalent secret on your own machine. Either way, use a different secret for development, staging and production, and rotate it straight away if it ever appears in a log, a screenshot or a public repository.

Frequently asked questions

Will changing APP_KEY break my app?

Anything encrypted with the old key (encrypted casts, some cookies) can no longer be decrypted. Laravel 11 can read old data if you list the previous key in APP_PREVIOUS_KEYS.