Coin flipper
Ten fair flips with seed 42 always give the same sequence, THTTHTHTTH: 4 heads and 6 tails. Change the number of flips or the seed to run a new experiment and compare the share of heads with one half. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Flips
- 10
- Seed
- 42
- Sequence string
- THTTHTHTTH
- Heads
- 4
- Tails
- 6
- Heads rate
- 0.4
A fair coin flipper is the simplest Bernoulli laboratory: each toss is independent, heads and tails are equally likely, and the only parameter that changes the experiment is how many times you flip. The same pair of inputs always yields the same sequence.
What a fair coin flipper actually returns
A fair coin has two faces with equal probability one half, and independent tosses form a Bernoulli process whose only design choice is the number of trials. A coin flipper therefore does not compute a binomial probability mass; it materializes a concrete sequence of outcomes so you can see the run of heads and tails, count streaks, or feed the list into a later chart.
The mapping is fixed, the generator is fixed, and the walk over flips is sequential, so the pair of flips and seed is a complete description of the experiment. Fairness is hard-coded at probability one half; this landing is not a biased-coin laboratory. When flips is not a positive integer the task fails instead of inventing a toss, because a zero-length or fractional experiment is not a coin flipper result that anyone can grade.
Where a seeded coin flipper earns its keep
Classrooms and tutoring platforms use a coin flipper so learners can watch a short fair sequence appear without flipping plastic coins at their desks, then compare the observed heads rate with the theoretical one half. Game designers and sports-tie tools need an auditable toss: given the published seed and the flip count, any later reviewer can recompute the exact heads and tails that decided a kickoff or a prize draw.
Developers call the same contract from scripts to seed unit-test vectors, to drive Monte Carlo demos that must match a printed worksheet, or to satisfy programming-challenge statements that demand a sequence rather than a single probability. Failed validation does not consume balance.
What you can do with it
Classroom Bernoulli demos
Let students submit a flip count and a shared class seed, then discuss the observed heads rate against the fair one-half model without physical coins.
Auditable game and contest tosses
Publish the seed and flip count for a kickoff, raffle, or tie-break so any later reviewer can recompute the exact heads and tails sequence.
FAQ
How do I simulate fair coin flips?
Send flips as a positive integer and optionally seed as an integer. Same inputs always produce the same tape.
What happens if the flip count is not a positive integer?
Zero, negatives, fractions, missing values, and counts above ten thousand are rejected and are not billed.
Is the coin fair, and can I bias it?
The coin is fair with p equal to one half. This landing does not accept a bias parameter; for binomial probabilities of exactly k heads use the sibling probability tool.
Why do I need a seed?
The seed makes the sequence reproducible. Omit it to use the default of one, or set your own integer so two machines, two graders, or a later audit reconstruct the same tosses.
Can I use the coin flipper to settle a tie or a prize draw?
Yes. Publish the seed and the number of flips you used, and anyone can later recompute the exact heads and tails sequence that decided the kickoff, raffle or tie-break.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/stat/coin-flipper \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"flips":10}'const res = await fetch("https://api.kit.forhosting.com/stat/coin-flipper", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"flips": 10
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/coin-flipper",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"flips": 10
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/coin-flipper", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"flips":10}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"flips":10}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/coin-flipper", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"flips": 10
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.coin_flipper",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
min_flips | 1 |
max_flips | 10000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
A flip count that is missing, zero, negative, or not an integer fails with invalid_input instead of inventing a toss.
What a fair coin flipper actually returns
This endpoint initializes a mulberry32 generator from the integer seed you send, then draws one uniform number in the unit interval for every flip and maps values below one half to heads (H) and the rest to tails (T). The response lists the sequence array, the compact sequence_string, the heads count, the tails count, and the heads rate so you can check the law of large numbers on modest n without writing a loop of your own. Identical inputs always produce identical JSON because the path never consults the wall clock or the host random source.
Input contract, response shape, and error behaviour
Example: ten flips with seed forty-two always produce the same ten-character tape and the same two counts. POST a JSON body with flips set to a positive integer from one through ten thousand; aliases n, count, and times are accepted when clients reuse older form names. Optional seed is a finite integer that initializes the generator; alias rng_seed maps to the same field, and omitting seed uses the documented default of one so a lone flip count still produces a stable tape. Each field may arrive as a JSON number or as a numeric string of digits; empty strings, booleans, objects, and non-integers fail with invalid_input naming the field. Zero, negative values, and counts above the published maximum are rejected because they are not a positive integer flip count inside the Worker budget. Those failures are not billed. On success the body echoes flips and seed, returns sequence as an array of H and T tokens in toss order, sequence_string as the same faces concatenated for easy copy, heads and tails as integer counts that always sum to flips, heads_rate as heads divided by flips rounded to twelve decimal places, p equal to one half, and fair equal to true so downstream code can branch without sniffing shapes. Pair the response with your own charting code if you need a histogram of run lengths; this endpoint only simulates the tosses. Keep n modest in interactive widgets, pin goldens for the seeds you ship, and treat invalid_input as a data-quality signal rather than retrying a malformed count.
Where a seeded coin flipper earns its keep
Exam-prep generators need a deterministic oracle that marks a wrong flip count as invalid_input instead of silently returning an empty list a buggy grader might treat as success. Keep requests inside the published flip cap, pin the rounded heads_rate in tests, and you get reproducible fair-coin sequences for homework, LMS plugins, and edge workers without standing up a custom random service of your own.
Integration use cases
Deterministic test fixtures
Generate a stable H/T tape in unit tests and Monte Carlo worksheets so CI and printed answer keys never drift between machines.
Technical questions
What does the coin flipper cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.