Free Tool

Cron Secret Generator

Generate a cryptographically secure CRON_SECRET key with one click. The secret is created locally in your browser using the Web Crypto API — copy it straight into your environment variables.

Format
Strength
Your generated secret
 

Generated locally in your browser with the Web Crypto API — nothing is ever sent to a server.

What is a CRON_SECRET?

A CRON_SECRET is a random token that protects your cron job endpoints from unauthorized access. Cron routes are ordinary HTTP endpoints — without a secret, anyone who discovers the URL can trigger your scheduled jobs, drain your quotas, or corrupt your data.

The scheduler sends the secret in the Authorization header of every cron request, and your endpoint rejects any request that doesn't carry it. A 32-byte random value is the widely recommended strength — the same as Vercel's official documentation suggests.

How to use CRON_SECRET with Vercel Cron Jobs

1. Add the generated key as a CRON_SECRET environment variable in your Vercel project settings.

2. Declare your cron schedule in vercel.json:

vercel.json
{
  "crons": [
    { "path": "/api/cron/daily-report", "schedule": "0 5 * * *" }
  ]
}

3. Verify the Authorization header in your route handler:

app/api/cron/daily-report/route.ts
// app/api/cron/daily-report/route.ts
import { NextResponse } from "next/server";

export async function GET(request: Request) {
  const authHeader = request.headers.get("authorization");
  if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }

  // ... run your scheduled job here

  return NextResponse.json({ ok: true });
}

Cron jobs on Dokploy, Coolify and other platforms

Self-hosted platforms like Dokploy and Coolify don't inject the Authorization header for you — schedule a curl command that sends it explicitly:

crontab
curl -X GET "https://your-app.com/api/cron/daily-report" \
  -H "Authorization: Bearer $CRON_SECRET"

Read the full cron jobs setup guide in the NEXTY.DEV docs

Frequently Asked Questions

How long should a CRON_SECRET be?

32 bytes (256 bits) of randomness is the recommended strength for a CRON_SECRET. That's what Vercel's documentation suggests and what this generator produces by default. Longer secrets add no practical security benefit.

Is it safe to generate a cron secret in the browser?

Yes. This tool uses the Web Crypto API (crypto.getRandomValues), which provides cryptographically secure randomness. The secret is generated entirely on your device and never transmitted anywhere.

How do I generate a CRON_SECRET from the command line?

Run `openssl rand -hex 32` for a hex secret or `openssl rand -base64 32` for a Base64 one. This generator produces the same class of secret without needing a terminal.

Do I need a different secret for each environment?

Yes, use separate secrets for development, preview and production. If a secret ever leaks, rotate it by generating a new one and updating the environment variable — no code change needed.

This free tool is built and maintained by NEXTY.DEV — the Next.js SaaS boilerplate that ships with cron jobs, auth, payments and AI already wired up.