Random Bytes Generator
Generate cryptographically secure random bytes in 9 output formats — hex, Base64, Base64URL, binary, decimal, C array, Python bytes, UUID v4.
How to use
- Pick byte count (1-256) — 16 for an IV, 32 for an HMAC key, 64 for an OAuth client secret.
- Choose the output format. Use Base64URL for cookies and JWTs (no padding, URL-safe).
- Click 'Generate' for a fresh value; changing options re-renders the existing bytes.
About this tool
ShowHide
Generates up to 256 bytes of cryptographically secure random data from the browser's crypto.getRandomValues(), formatted for wherever it is going: lowercase or uppercase hex, standard or URL-safe Base64, a binary string, a decimal byte array, a C uint8_t literal, a Python b'...' literal, or an RFC 4122 version 4 UUID once you have asked for sixteen bytes or more. Separators — none, space, comma, colon or dash — let the output match a MAC address, a certificate fingerprint or whatever your config file expects.
The distinction that matters is the source. Math.random() is a fast pseudo-random generator built for shuffling and animation, and its output is predictable to anyone who observes enough of it — a session token drawn from it is not a secret. crypto.getRandomValues() draws from the operating system's cryptographic generator, which is seeded from hardware entropy and designed so that seeing past output tells you nothing about future output. Every secret belongs in the second category, and there is no performance reason to prefer the first.
How many bytes is a real question with a boring answer: 16 bytes is 128 bits, which is the conventional floor for anything a stranger might try to guess, and 32 bytes is what you want for a long-lived secret such as a signing key. Encoding changes the length but not the strength — 16 bytes is 32 hex characters or 24 Base64 characters, all carrying the same 128 bits — so a longer-looking string is not a stronger one. URL-safe Base64 is worth choosing over the standard alphabet for anything that will appear in a path or query string, since + and / need escaping there and = padding is often stripped in transit.
The UUID option has a detail people miss. A version 4 UUID is 128 bits wide but only 122 of them are random; four bits record the version and two record the variant. That is still far beyond collision range, but if you are budgeting entropy for a token, count 122 and not 128 — and if you need the full 128, take the raw bytes as hex instead.
Frequently asked questions
Is this cryptographically secure?
Yes. It uses crypto.getRandomValues(), the Web Crypto API's CSPRNG. All generation happens locally in your browser — bytes never leave your device.
Why 256 bytes max?
For most security uses (keys, tokens, salts) you need 16-64 bytes. Capping prevents accidentally locking the UI with multi-MB output. Use a CLI tool (openssl rand, head /dev/urandom) for large amounts.
What's the difference between Base64 and Base64URL?
Base64 uses +, /, and = padding — fine for JSON but unsafe for URLs and filenames. Base64URL replaces + → -, / → _, drops = padding — used in JWTs, OAuth state, and URLs.
Is a key generated in a browser tab safe to use in production?
The randomness is; the handling is what to think about. The value passes through a page, a clipboard, quite possibly a chat window on the way to a colleague, and whatever synced clipboard history the operating system keeps. For a secret that guards something real, generate it where it will live — the server, the key manager, the deployment pipeline — and use a browser only for throwaway values.
How many bytes is enough?
Sixteen random bytes is 128 bits, which is beyond brute force and is what most token and key formats settle on; thirty-two is the usual choice where a longer key costs nothing. Length only helps if every byte is random, though — a 32-byte value built from a memorable phrase carries the entropy of the phrase, not of its length.
Guides on this topic
Related tools
UUID Generator
Generate random version-4 UUIDs in bulk, with copy.
Developer
Password Generator
Generate strong, random passwords that never leave your browser.
Random
Tailwind Color Palette
The full Tailwind CSS v4 default palette — 22 hues × 11 shades, 50 through 950 — with click-to-copy as Tailwind class, HEX, or rgb().
Color & CSS
Random Color Generator
Generate a grid of random colors in HEX, RGB or HSL — pick how many, copy any value with one click, and regenerate instantly for design inspiration.
Random
Unicode Character Inspector
Break a string into characters and show each codepoint, UTF-8 bytes, HTML entity, CSS escape, and Unicode block.
Text
DNS Message Decoder
Paste a DNS packet as hex or DoH base64url and read it: header flags, opcode and rcode, every record, and the EDNS0 OPT options.
Network