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
- Turn on Num Lock.
- Hold the left Alt key.
- Type 95 on the numeric keypad.
- 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
- Tap 123 in the lower left of the on screen keyboard.
- The underscore sits on the main punctuation page next to the hyphen.
- 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.




