Skip to content
webtype.orgwebtype.org

    ↑↓ move · ⏎ open · esc close

    Strings

    Lowercase

    Lower-cases a string literal type.

    What it is

    The mirror of Uppercase, and intrinsic in the same way. Its most common real use is not transformation but comparison: pairing it with Uppercase is how you ask whether a character is a letter at all.

    Examples

    • Lowercase<'HELLO'>
      →"hello"
    • Lowercase<'MiXeD'>
      →"mixed"
    • Uppercase<'7'> extends Lowercase<'7'> ? true : false
      →true

    Each resolved type above was printed by TypeScript 6.0.3, not written by hand.

    What it does not do

    • It does not tell you a character is a letter on its own. Lowercase<"7"> is "7", and only comparing against Uppercase reveals that there was no case to change.
    • It does not distribute the way you might hope over a template. Applying it to a whole string lower-cases everything, not the first character.

    Takeaway

    Uppercase<C> extends Lowercase<C> is true exactly when C has no case — the cleanest letter test the type system offers.