Skip to main content
    Tech & Gadgets

    How Do I Type the Underscore Symbol on Any Keyboard?

    Mark Debson

    Mark Debson

    Author

    How Do I Type the Underscore Symbol on Any Keyboard?Save

    Quick Answer

    On every standard QWERTY keyboard, hold Shift and press the hyphen key (right of the 0). The result is the underscore character (_). On a Mac the combination is identical: Shift + minus.

    On phones, switch to the number layer with 123 or ?123 and the underscore sits in the punctuation row, usually behind a long press on the hyphen.

    What the underscore is for

    The underscore character (_, Unicode U+005F) is one of the most important "joining" characters in modern computing. It glues words together in file names where spaces are not allowed (annual_report_2026.pdf), in variable names in code (user_id, total_count), and in database column names.

    It is also the standard convention for snake case naming in Python, Ruby, Rust, SQL, and most shell scripting languages. Knowing where the key lives is non negotiable for anyone writing code, sharing files across operating systems, or building URLs.

    The fast reference table

    • US ANSI keyboard: Shift + hyphen (right of 0)
    • UK ISO keyboard: Shift + hyphen (right of 0)
    • German QWERTZ: Shift + the dash key (right of ß)
    • French AZERTY: Shift + 8
    • Mac (any layout): Shift + hyphen
    • Windows Alt code: Alt + 95 on the numeric keypad
    • iOS or Android: tap 123, then long press the hyphen
    • Linux or Chromebook: Ctrl + Shift + U, type 005f, press Enter

    Finding the underscore on US and UK keyboards

    The underscore shares a key with the hyphen on every English language keyboard. The key sits in the top right of the number row, between the 0 and the equals sign. Press the key on its own for a hyphen, hold Shift while pressing it for the underscore.

    Some compact 60 percent mechanical keyboards shrink or move this key. Check the layout map for your specific board if Shift plus the expected position does nothing.

    Finding the underscore on European keyboards

    German QWERTZ

    The hyphen sits to the right of the ß key in the bottom right of the alpha block. Hold Shift while pressing it for the underscore.

    French AZERTY

    French keyboards do not put the hyphen in the same location as English layouts. On a standard AZERTY board, hold Shift and press the 8 key. The label _ is usually printed in the upper portion of the 8 keycap.

    Spanish

    The hyphen sits next to the 0 key, but the underscore is reached with Shift plus the same key on Spain and Latin American Spanish boards.

    Finding the underscore on a Mac

    The Mac keeps the hyphen and underscore on the same key across every regional layout. Shift + hyphen produces _ on US, British, Spanish, German, and French Macs. The position is identical to a Windows keyboard.

    When the key does not exist

    Ultra compact gaming keyboards and some travel laptops occasionally drop the hyphen key entirely. Three fallbacks cover every case.

    Windows Alt code

    1. Turn on Num Lock.
    2. Hold the left Alt key.
    3. Type 95 on the numeric keypad.
    4. Release Alt.

    Linux and Chromebook

    Press Ctrl + Shift + U, type 005f, then press Enter or Spacebar.

    Mac Character Viewer

    Press Control + Command + Spacebar, search "low line" (the official Unicode name for the underscore), and double click to insert.

    Underscore on mobile devices

    iOS

    1. Tap 123 in the lower left of the on screen keyboard.
    2. The underscore sits on the main punctuation page next to the hyphen.
    3. If you cannot see it, tap #+= for the secondary symbol panel.

    Android

    Tap ?123 to switch to the symbol layer. Long press the hyphen key. The underscore appears in the popup. Drag your finger onto it and release.

    Snake case best practices

    The underscore is the foundation of snake case naming, the most common convention in Python, Ruby, Rust, and SQL.

    • Variable names: total_revenue, customer_email, last_updated_at.
    • File names: quarterly_report_2026.pdf, marketing_assets_final.zip.
    • Database columns: user_id, created_at, is_active.
    • URL slugs: some platforms still allow underscores in slugs, but most SEO best practice now favours hyphens because search engines treat the hyphen as a word separator and the underscore as a word joiner.

    Pick one convention per project and stick with it. Mixing snake_case and camelCase inside a single codebase makes search and refactor painful.

    HTML and CSS

    The underscore does not need an HTML entity; it is a printable ASCII character that renders directly in markup. CSS class names can include underscores (.user_profile), although most modern style guides prefer kebab case (.user-profile) for readability.

    In Markdown, a single underscore around a word renders as italic (_italic_) and a double underscore renders as bold (__bold__). Escape with a backslash if you want a literal underscore inside Markdown body text.

    Troubleshooting

    Shift plus the hyphen prints a number instead

    You are pressing a number key by mistake. The hyphen key is always to the right of the 0, not the 0 itself.

    The key prints an en dash instead of an underscore

    An autocorrect or text replacement rule is converting Shift + hyphen into an en dash. Disable smart punctuation in your editor settings.

    My French keyboard prints an 8 with Shift

    French AZERTY puts the underscore on Shift + 8 only when the bottom layer of the 8 key is the hyphen. Some older AZERTY boards use a different mapping. Check the printed labels on the 8 keycap.

    FAQs

    What is the Unicode name for the underscore?

    Low line, code point U+005F. The decimal value is 95, which is what the Windows Alt code uses.

    Should I use underscores or hyphens in URLs?

    Hyphens. Google treats hyphens as word separators in URL slugs, so /quarterly-report-2026 reads as three separate keywords. Underscores are treated as word joiners, so /quarterly_report_2026 reads as a single token. Hyphens are better for SEO.

    Why do Python and Ruby prefer snake case?

    Both languages were designed with readability as a core principle. The underscore between words creates a visible gap without forcing capital letters, which makes long names easier to scan.

    The takeaway

    The underscore is Shift plus the hyphen on every English keyboard and almost every European one. Memorise the one position and the rest of your file naming, code writing, and database design becomes invisible muscle memory.

    My typing & keyboard picks

    Tap any card to check today's price.

    Mark Debson

    Written by

    Mark Debson

    I'm Mark Debson, the writer behind dmbio. I spend my days digging into the science behind everyday products, brands and habits, then translating what I find into clear answers you can read in about five minutes.

    Drafted with AI assistance, fully reviewed and edited before publishing. See our editorial & AI policy.

    Related reads