Understanding the key signature calculator — concept and principle
This calculator shows the key signature of any major or minor key: how many sharps or flats it has, which ones in order, and its relative, parallel and enharmonic keys. Music students use it for theory homework; players use it to read and transpose music.
How it is calculated
- Each key's position on the circle of fifths gives its signature: each step clockwise from C (C → G → D …) adds a sharp; each step anticlockwise (C → F → B♭ …) adds a flat.
- Sharps are written in the order F♯ C♯ G♯ D♯ A♯ E♯ B♯; flats in the reverse order B♭ E♭ A♭ D♭ G♭ C♭ F♭.
- Relative key: a minor key shares its signature with the major key a minor third above it (A minor ↔ C major).
- Parallel key: same tonic, other mode (D major ↔ D minor).
- Enharmonic key: keys with 5–7 accidentals have a twin that sounds the same but is spelled differently (B major = C♭ major).
The principle
A major scale has a fixed pattern of whole and half steps. Starting the pattern on a new note forces some notes to be raised or lowered, and the key signature lists those changes once at the start of each staff. Moving up a fifth keeps six of the seven notes and raises one by a semitone, which is why each step round the circle of fifths adds exactly one sharp. Moving down a fifth adds a flat instead. A minor key and its relative major use the same seven notes, so they share a signature.
Worked example
Default input: D major.
- D is two steps clockwise from C (C → G → D), so the signature is 2♯: 2 sharps, 0 flats.
- The first two sharps in order: F♯ C♯.
- Relative minor: a minor third below D is B, so B minor.
- Parallel key: D minor (one flat).
- Enharmonic equivalent: D major has only 2 sharps, so none (—).
How to read the result
When you see two sharps at the start of a piece, it is in D major or B minor; look at the last chord and the bass to decide which. The signature applies to every octave of those notes unless an accidental changes it. Keys with many accidentals are often rewritten in their enharmonic twin to make reading easier.
Common mistakes
- Writing sharps in the wrong order.
- Confusing relative keys (same signature) with parallel keys (same tonic).
- Expecting the raised leading note of a minor key to appear in the signature; it is written as an accidental.
- Forgetting that F major has one flat, not one sharp.
Frequently asked questions
How many sharps are in D major?
Two: F♯ and C♯.
What is the relative minor of D major?
B minor, which shares the same two sharps.
What is the order of sharps?
F, C, G, D, A, E, B; flats are the same letters in reverse.
Sources: S. Kostka, D. Payne & B. Almén, Tonal Harmony, 8th ed. (McGraw-Hill, 2018), ch. 1 (key signatures and the circle of fifths)