Username regex for api?

I am creating a web app that will have twitch login support. Users can also create an account on their own with username, email, etc. I would love it if I could get the regex you are using to validate usernames on Twitch so I can make mine match. It would seem strange if a char was allowed in a twitch created account, but not on an account created via email signup. I just want some continuity between the different account types.

A-Z 0-9 and _ are the allowed characters in a username.

A while ago, I made my own regex to validate usernames for my chat bot. I came up with this pattern:

[1][\w]{3,24}$

Why “[a-zA-Z0-9]” at the beginning? Because it seems like an underscore isn’t allowed as first character (can someone confirm this?)


  1. a-zA-Z0-9 ↩︎

I can confirm that a username cannot start with an underscore. They also cannot contain ‘bad words,’ although I’m not sure if there’s a list somewhere of all the words Twitch sees as bad.

Keep in mind those criteria are only suggested, and that there are names that go outside of them. Usually those are really old usernames, or they are created by Twitch. Usernames can also contain ‘bad words’ if they were added before the ‘bad words’ were.