Random string generator

Generate alphanumeric or hex strings with crypto.getRandomValues.

{{ randomString.message }}

{{ t("randomStrMaxLen") }}

Overview

Computers are deterministic machines: given the same initial state, they execute exactly the same operations and produce exactly the same results. This is an enormous virtue for reliability and debugging, but a serious problem when you need randomness. The historical solution was the pseudorandom number generator (PRNG): an algorithm that, given an initial number called a seed, produces a sequence that looks random but is entirely deterministic. The Linear Congruential Generator (LCG), formalized by D. H. Lehmer in 1948, was the standard for decades: take the previous number, multiply by a constant, add another value, and take the remainder of a modular division. Simple, fast, implementable in a few lines. The problem is that LCGs have predictable patterns given enough output — in 1993, the online game Netrek was compromised because its pseudorandom authentication token generator was an LCG with known parameters that were easy to reverse-engineer.

The Web Crypto API, available in all modern browsers, solves the problem with `window.crypto.getRandomValues()` — a function that requests genuine entropy from the operating system. This entropy comes from physical noise sources: mouse movements, disk timings, hardware interrupts, network activity. Linux accumulates this entropy in a special pool and makes it available to processes. JavaScript's `Math.random()` — despite using modern algorithms like xorshift128+ in the V8 engine — is not suitable for security purposes because its seed can be predictable depending on the implementation and is not protected against analysis. For any string intended for authentication, session tokens, unique IDs, or CSRF tokens, `getRandomValues()` is the correct standard.

In practice, random strings are needed in more places than most developers realize. Resource IDs in REST APIs need to be unique and preferably non-sequential — sequential IDs expose data volume and make enumeration easier for attackers. API access tokens need to be long enough to resist brute force: a 32-byte hex string has 256 bits of entropy, which is today's minimum acceptable standard for secrets. Temporary passwords for account reset flows. Unique temporary file names to avoid race conditions. The birthday paradox has practical implications here: for 8-character alphanumeric IDs (62 possible symbols), the probability of collision starts to be significant at around 218,000 generated IDs. For 16 characters, the number rises to 14 billion. This tool uses `getRandomValues()` and supports configurable length, alphabet, and encoding.

Technical deep dive

Common questions summarized

  • What is this tool for?: It runs fully in your browser: useful to validate, format, or convert data in everyday development.
  • Are my inputs sent to a server?: Processing happens locally with JavaScript. We do not store what you paste into the text areas.
  • Can I use this for real production data?: Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.

Sample payload to try

  • See also the larger "Code Snippets" sample; paste this excerpt to try locally: Use — IDs de teste: 16 caracteres [a-zA-Z0-9]

Tool guide

  • What a random string is An unpredictable sequence drawn from a chosen alphabet.

  • What the tool does Generates a configurable length using crypto.getRandomValues, with alphanumeric, hex, or a custom character set.

  • Why use it Test IDs and sample values. For password policies with symbol rules, also use the site’s password generator.

Code Snippets

Code example
IDs de teste: 16 caracteres [a-zA-Z0-9]

Use

IDs de teste: 16 caracteres [a-zA-Z0-9]

FAQ

What is this tool for?

It runs fully in your browser: useful to validate, format, or convert data in everyday development.

Are my inputs sent to a server?

Processing happens locally with JavaScript. We do not store what you paste into the text areas.

Can I use this for real production data?

Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.