Home / Secret Key Generators / Django

Django SECRET_KEY Generator

Generate a Django SECRET_KEY: 50 characters by default, using the same character set as Django’s own get_random_secret_key(), entirely in your browser.

100% client-side No account, no sign-up Matches Django’s own default charset

Django SECRET_KEY Generator

50 is Django’s own default. Longer is fine; Django doesn’t cap the length.

Click Generate to create one.

Or generate it with Django itself

If you’d rather generate the key locally instead of pasting from a web page, Django ships a built-in function for exactly this:

from django.core.management.utils import get_random_secret_key

print(get_random_secret_key())
# 50 characters, drawn from Django's own default charset

Then in settings.py: SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]. Read it from an environment variable, never commit it to version control.

How this tool works

This tool matches Django’s own get_random_secret_key() character set: lowercase letters, digits, and the symbols !@#$%^&*(-_=+) (no uppercase, matching Django’s default). Randomness comes from the Web Crypto API’s crypto.getRandomValues() in your browser, the same category of cryptographically secure source Django’s own function draws from via Python’s secrets module.

Sources:

Frequently asked questions

How long should a Django SECRET_KEY be?

Django’s own generator defaults to 50 characters, which is the widely-used standard. Django does not enforce a maximum length, so going longer is safe if you want extra margin.

Where should I store my SECRET_KEY?

In an environment variable, read via os.environ, never hardcoded in settings.py or committed to version control. If a key is ever exposed, generate a new one and redeploy immediately. Django’s docs note that a known key defeats several of its built-in security protections.