Generating user-facing identifiers
Shorter and cleaner than a UUID in URLs, without hyphens breaking on double-click selection. Common for share links and document IDs.
Generates compact, URL-friendly, cryptographically secure unique string IDs with customizable alphabets and length.
—Generates compact, URL-friendly, cryptographically secure unique string IDs with customizable alphabets and length.
Length: 21, Alphabet: default URL-safe
V1StGXR8_Z5jdHi6B-myT
21 characters provide equivalent collision resistance to UUID v4.
A compact, collision-safe random identifier suitable for URLs and database keys.
Your input is processed entirely in your browser and never sent to a YAS server.
curl -X POST "https://yas.sh/api/v1/tools/nanoid-generator" \
-H "Content-Type: application/json" \
-d '{"count":1,"size":21}'const res = await fetch("https://yas.sh/api/v1/tools/nanoid-generator", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"count": 1,
"size": 21
}),
});
const data = await res.json();import requests
r = requests.post("https://yas.sh/api/v1/tools/nanoid-generator", json={"count":1,"size":21})
data = r.json()| Field | Type | Required | Description |
|---|---|---|---|
| count | integer | No (default 1) | Count (1–50) |
| size | integer | No (default 21) | ID length (4–128) |
| alphabet | string | No | Custom alphabet |
{ "slug": "nanoid-generator", "count": 1, "size": 21, "result": "V1StGXR8_Z5jdHi6B-myT" }Generate compact URL-friendly unique IDs.
400 VALIDATION_ERROR — invalid input or unsupported option.413 PAYLOAD_TOO_LARGE — input exceeds the 64 KB limit.429 RATE_LIMIT_EXCEEDED — rate limit exceeded (60 req/min).NanoID generates a random string from a 64-character URL-safe alphabet (A–Z, a–z, 0–9, _, -), drawing bytes from the platform CSPRNG and mapping them uniformly with rejection sampling. Each character contributes 6 bits, so the default 21-character ID carries 126 bits of entropy — comparable to a UUID v4's 122 bits in a string 40% shorter and with no hyphens.
The collision arithmetic follows the birthday bound: at 126 bits you would need roughly 10^18 IDs before a meaningful collision probability. Shortening the ID is a deliberate trade — a 10-character ID has 60 bits, which is fine for a few million values and unwise for a global namespace, and the honest way to choose a length is to compute the bound for your expected volume rather than to pick a number that looks tidy.
Shorter and cleaner than a UUID in URLs, without hyphens breaking on double-click selection. Common for share links and document IDs.
Client-side identity for list rendering and label/input association, where uniqueness within the page is all that is required.
Keeps the numeric primary key private while giving the API a stable, non-enumerable public handle.
URL-safe by construction, so no percent-encoding is needed anywhere in the path.
What this tool deliberately does not do, and where it will disagree with other implementations.