Key from sharps or flats count
Two sharps mean D major or B minor, with F-sharp and C-sharp in the signature. Enter how many sharps or flats you see, from none to seven, and name the key for sight-reading, dictation or score study. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Quantity
- 2
- Kind
- sharp
- Major key
- D
- Minor key
- B
- Major name
- D major
- Minor name
- B minor
Reading a staff and knowing which major and minor keys share a given key signature is a core skill in music theory, dictation, and score study. Students count the sharps or flats and then recall the circle of fifths; teachers and app builders need the same mapping without hand-rolled tables that disagree on Cb major or A# minor. This key-from-accidentals calculator accepts an integer count from zero through seven and a kind of sharp or flat, then returns the major key, its relative natural minor, the ordered list of accidentals in signature order, and a human-readable signature label. Zero accidentals is C major and A minor for either kind.
How key signatures map to major and minor keys
In equal-tempered tonal practice, every standard key signature is a point on the circle of fifths. Starting from C major with no accidentals, each added sharp moves the major tonic a fifth up (G, D, A, E, B, F sharp, C sharp) while each added flat moves it a fifth down (F, B flat, E flat, A flat, D flat, G flat, C flat).
The relative minor always sits a minor third below the major tonic—or three semitones down—so the same signature serves both: two sharps are D major and B minor; three flats are E flat major and C minor. Accidentals themselves appear in a fixed order that never changes: sharps are F sharp, C sharp, G sharp, D sharp, A sharp, E sharp, B sharp; flats are B flat, E flat, A flat, D flat, G flat, C flat, F flat.
Counting how many symbols appear on the staff therefore fully determines both the major and the relative minor key and the exact pitch names that are raised or lowered.
When a quick key signature check helps
Theory classrooms and exam generators use a key from sharps or flats count calculator so learners can check that four sharps are E major and C sharp minor without flipping mnemonic cards. Sight-singing and ear-training apps need a deterministic oracle when a drill shows a signature and asks for both relative keys. Notation editors, chord-chart tools, and capo helpers often know how many accidentals a passage uses and must surface the concert key name for the user.
Content sites that rank for key signature calculator or how many sharps in D major benefit from a live free browser path that matches the paid automation path on the same pure module. Failed validation does not consume balance. Keep counts in the standard zero-to-seven range, pin the ordered accidentals in tests, and you get reproducible theory answers for homework, LMS plugins, and edge workers without standing up a full musicXML stack.
What you can do with it
Theory homework and exams
Let students enter how many sharps or flats they counted on the staff and verify the major key, relative minor, and accidental list against the textbook circle of fifths.
Notation and chart tooling
Resolve a counted signature into concert key names and ordered accidentals inside editors, lead-sheet generators, and rehearsal apps without embedding theory tables in every client.
FAQ
How do I find the major and minor key from a number of sharps?
Send count (0–7) and kind "sharp". Example: count 2 → D major and B minor with F# and C#.
What about flats?
Use kind "flat" (or flats, b). Count 3 returns Eb major, C minor, and accidentals Bb, Eb, Ab. Count 0 is C major / A minor for either kind.
Why is the maximum count 7?
Standard tonal key signatures use at most seven sharps (C# major) or seven flats (Cb major).
Is the minor key harmonic or melodic?
Raised leading tones of harmonic or melodic minor are not part of the key signature itself.
What key has two sharps?
D major, or its relative minor, B minor. The two sharps are F-sharp and C-sharp, and they always appear in that order in the key signature.
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/hobby/music-key-from-accidentals \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"count":2,"kind":"sharp"}'const res = await fetch("https://api.kit.forhosting.com/hobby/music-key-from-accidentals", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"count": 2,
"kind": "sharp"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/hobby/music-key-from-accidentals",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"count": 2,
"kind": "sharp"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/hobby/music-key-from-accidentals", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"count":2,"kind":"sharp"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"count":2,"kind":"sharp"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/hobby/music-key-from-accidentals", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"count": 2,
"kind": "sharp"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "hobby.music_key_from_accidentals",
"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.
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
Input contract, response fields, and validation
Pair the response with your own staff rendering if you need glyphs; this capability names keys and accidentals only. POST a JSON body with two required fields: count, an integer from zero through seven inclusive (aliases n, accidentals, num, number), and kind, a string that normalizes to sharp or flat (accepts sharp, sharps, #, s and flat, flats, b, f, case-insensitive; aliases type, accidental, accidental_type, side). Missing fields, non-integers, counts outside zero to seven, and unrecognized kind strings fail with invalid_input and are not billed. On success the body echoes count and the normalized kind, then major_key and minor_key as compact pitch-letter names with accidental signs when needed (for example F# and Bb), major_name and minor_name as display phrases such as D major and B minor, signature as a short label like 2 sharps or no sharps or flats, accidentals as an ordered array of pitch names in signature order, accidental_list as a comma-separated string or none, and circle_position as a signed integer on the circle of fifths (positive for sharps, negative for flats, zero at C). Example: count two and kind sharp yields major D, minor B, accidentals F# and C#, and circle_position two.
Integration use cases
Ear-training and drill apps
Drive signature-to-key drills with a deterministic API that always maps 0–7 accidentals to the same major and minor pair for grading and spaced repetition.
Technical questions
What does the key signature calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.