Generator Utilities

Roll Dice

Generates truly random dice rolls for any number of dice with customizable sides. Use via MCP in Cursor or Claude Code, or call GET /v1/generate/dice directly. Returns individual roll values plus sum — perfect for D&D campaigns, probability simulations, or game development. Uses cryptographically secure randomness, not pseudorandom algorithms.

API Endpoint

GET /v1/generate/dice

Code Examples

curl "https://tinyfn.io/v1/generate/dice" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/generate/dice', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/generate/dice',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's generator tools:

{
  "mcpServers": {
    "tinyfn-generator": {
      "url": "https://tinyfn.io/mcp/generator",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I roll multiple dice with different numbers of sides?

Specify the number of dice and sides per die in your request. For example, roll 3d6 for three six-sided dice, or 2d20 for two twenty-sided dice.

Can I use this dice roller in my MCP-enabled AI coding assistant?

Yes, the tool works directly in Cursor, Claude Code, Windsurf, and other MCP clients. Just ask your AI to roll dice and it will call the function automatically.

What's the difference between this and using Math.random() for dice rolls?

This uses cryptographically secure randomness instead of pseudorandom generators, ensuring truly unpredictable results for fair gameplay or statistical sampling.

Does the API return individual dice values or just the total?

Both — you get an array of individual roll results plus the calculated sum, useful for games that need to know specific die outcomes.

What's the maximum number of dice I can roll at once?

The API accepts reasonable limits to prevent abuse, typically supporting standard tabletop gaming scenarios with dozens of dice per roll.

Try Roll Dice Now

Get your free API key and start using Roll Dice in seconds.

Get Free API Key