About the Key Signature Calculator
A key signature is the set of sharp or flat symbols placed at the start of a musical staff, telling a performer which notes are consistently raised or lowered for the rest of the piece (or until the next key signature change). This calculator uses the standard line of fifths — the same integer arithmetic used by music notation software — to work out any major or minor key's signature directly from its tonic note.
The formula: line of fifths
Every note letter has a fixed position relative to C on the circle of fifths: F = −1, C = 0, G = 1, D = 2, A = 3, E = 4, B = 5. A sharp on the tonic adds 7 to that position; a flat subtracts 7. For a minor key, subtract 3 more, because the minor tonic sits a minor third below the letter-name major tonic that shares its signature. The result is a single number, the fifths value:
- Positive fifths value = that many sharps (e.g. +3 = 3 sharps).
- Negative fifths value = that many flats (e.g. −4 = 4 flats).
- Zero = no sharps or flats (C major or A minor).
For example, D major: D's base position is 2, no accidental, major mode, so the fifths value is 2 → 2 sharps (F♯ and C♯). B♭ minor: B's base position is 5, minus 7 for the flat, minus 3 for minor, giving 5 − 7 − 3 = −5 → 5 flats (B♭, E♭, A♭, D♭, G♭).
Which specific notes are altered
Sharps are always added in the fixed order F, C, G, D, A, E, B; flats in the exact reverse, B, E, A, D, G, C, F. A key with N sharps always uses the first N letters of the sharp order — never a different combination — so 4 sharps always means F♯, C♯, G♯, and D♯.
Relative major and minor keys
Every major key shares its exact key signature with one minor key, called its relative minor, whose tonic sits a minor third (3 semitones) below the major tonic. G major and E minor both use one sharp (F♯); C major and A minor both use none. The calculator reports this relative key alongside the signature.
Enharmonic equivalents
Practical key signatures range from 7 flats to 7 sharps — 15 keys in total, from C♭ major to C♯ major. Near the middle of that range, keys like C or G major have no simple alternate spelling. Near the edges, two spellings of the same pitches both stay inside the 15-key range: B major (5♯) is the same pitches as C♭ major (7♭), and F♯ major (6♯) is the same as G♭ major (6♭). If you enter a tonic that would require double sharps or double flats to notate (a "theoretical" key, such as G♯ major), the calculator automatically shows its practical enharmonic equivalent instead.