Generate Random String
This service task generates a random string with configurable character sets and length.
It uses Node.js crypto.randomBytes for cryptographically secure randomness.
Benefit: Tokens, reference codes, temporary passwords, or unique identifiers can be generated directly within a process — no external tools required.
Input Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
length |
Number | No | Length of the random part (excluding prefix/suffix). Default: 16. Maximum: 1024. |
numbers |
Boolean | No | Include digits (0–9). Default: true. |
characters |
Boolean | No | Include letters (a–z, A–Z). Default: true. |
specialSigns |
Boolean | No | Include special characters (!@#$%^&*…). Default: false. |
uppercase |
Boolean | No | Include uppercase letters (only relevant if characters is false). Default: true. |
prefix |
String | No | Fixed prefix prepended to the result. |
suffix |
String | No | Fixed suffix appended to the result. |
Example Input
{
"length": 24,
"numbers": true,
"characters": true,
"specialSigns": false,
"prefix": "REF-"
}
Output
| Field | Type | Description |
|---|---|---|
result |
String | The generated random string (including prefix/suffix). |
length |
Number | Total length of the result string. |
config |
Object | The character set configuration that was applied. |
Example Output
{
"result": "REF-aX7kQ9mB2nR4wL6pY8vT3j",
"length": 28,
"config": {
"numbers": true,
"characters": true,
"specialSigns": false,
"uppercase": true
}
}
Behaviour
- If all character type flags are set to
false, lowercase letters are used as a fallback. - The
prefixandsuffixare not counted towards thelengthparameter —lengthonly controls the random part. - Randomness is generated using
crypto.randomBytes, making it suitable for security-relevant use cases.
Use Cases
- Reference codes: Generate unique order or ticket IDs like
ORD-aX7kQ9mB. - Temporary passwords: Create initial passwords for user provisioning.
- API tokens: Generate bearer tokens or API keys within a workflow.
- File names: Create unique, collision-free file identifiers.
- Verification codes: Generate numeric-only codes for SMS/email verification.