Home / Secret Key Generators / Rails

Rails secret_key_base Generator

Generate a Rails secret_key_base: 128 hex characters, the same format the built-in "rails secret" command produces, entirely in your browser.

100% client-side No account, no sign-up 128 hex chars, matches "rails secret" output format

Rails secret_key_base Generator

Click Generate to create one.

Or generate it with Rails itself

Rails ships a built-in command that does exactly this locally, if you’d rather not paste a secret from a web page:

$ rails secret
# outputs 128 hex characters (64 random bytes)

Set it via ENV["SECRET_KEY_BASE"] or your credentials store. Never commit it directly into config/.

How this tool works

This matches the output format of Rails’ own rails secret command: 128 hexadecimal characters, representing 64 bytes (512 bits) of randomness. This tool generates it via the Web Crypto API’s crypto.getRandomValues() in your browser, the same class of cryptographically secure source rails secret draws from via Ruby’s SecureRandom.hex(64).

Sources:

Frequently asked questions

What is secret_key_base used for in Rails?

It’s the root key Rails uses to sign and encrypt cookies, sessions, and other sensitive data. If it’s exposed, an attacker could potentially forge session data.

Why 128 hex characters specifically?

That’s the output length of Ruby’s SecureRandom.hex(64): 64 random bytes, each represented as 2 hex characters, which is exactly what the built-in rails secret command generates.