100 Regex Patterns To Hunt Secrets Inside Javascript

When performing reconnaissance or source code reviews, JavaScript files are a goldmine of leaked credentials, secrets, tokens, and other sensitive artifacts. This blog post is a curated resource library of 100 regex patterns designed to help security researchers and engineers identify such exposures quickly during penetration tests or bug bounty assessments.
Use these patterns in automated scans or plug them into tools like grep
, ripgrep
, or Jsmon's own scanning engine to surface critical findings.
🔑 API Keys & Tokens
1. AWS Access Key IDAKIA[0-9A-Z]{16}
2. AWS Secret Access Key(?i)aws(.{0,20})?(?-i)['\"][0-9a-zA-Z\/+]{40}['\"]
3. Google API KeyAIza[0-9A-Za-z\\-_]{35}
4. Firebase SecretAAAA[A-Za-z0-9_-]{7}:[A-Za-z0-9_-]{140}
5. GitHub Tokenghp_[0-9a-zA-Z]{36}
6. GitLab Tokenglpat-[0-9a-zA-Z-_]{20}
7. Slack Tokenxox[baprs]-([0-9a-zA-Z]{10,48})?
8. Stripe Secret Keysk_live_[0-9a-zA-Z]{24}
9. Stripe Publishable Keypk_live_[0-9a-zA-Z]{24}
10. Twilio API KeySK[0-9a-fA-F]{32}
11. SendGrid API KeySG\.[\w\d\-_]{22}\.[\w\d\-_]{43}
12. Mailgun API Keykey-[0-9a-zA-Z]{32}
13. Dropbox Access Tokensl.[A-Za-z0-9_-]{20,100}
14. Shopify Access Tokenshpat_[0-9a-fA-F]{32}
15. Facebook Access TokenEAACEdEose0cBA[0-9A-Za-z]+
16. Heroku API Key[hH]eroku['\"][0-9a-f]{32}['\"]
17. DigitalOcean Tokendop_v1_[a-z0-9]{64}
18. Asana Personal Access Token0/[0-9a-z]{32}
19. Linear API Keylin_api_[a-zA-Z0-9]{40}
20. Telegram Bot Token\d{9}:[a-zA-Z0-9_-]{35}
🔐 OAuth & JWT
21. OAuth Client Secret(?i)client_secret['"\s:=]+[a-zA-Z0-9\-_.~]{10,100}
22. OAuth Client ID(?i)client_id['"\s:=]+[a-zA-Z0-9\-_.~]{10,100}
23. JWT TokeneyJ[A-Za-z0-9-_=]+?\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*
24. Azure Client Secret(?i)azure(.{0,20})?client.secret(.{0,20})?['\"][a-zA-Z0-9._%+-]{32,}['\"]
25. Microsoft Teams Webhookhttps:\/\/[a-z]+\.webhook\.office\.com\/webhookb2\/[a-zA-Z0-9@\-]+\/.*
🔒 Credentials & Passwords
26. Basic Auth String(?i)(username|user|email)['"\s:=]+[^\s'"@]{1,100}['"].*?(password|pwd)['"\s:=]+[^\s'"]{4,100}
27. Password Assignment(?i)(password|pwd|pass)['"\s:=]+[^\s'"]{4,100}
28. API Key in Variable(?i)(api[_-]?key)['"\s:=]+[a-zA-Z0-9\-_.]{8,100}
29. Secret in Variable(?i)(secret|token)['"\s:=]+[a-zA-Z0-9\-_.]{8,100}
30. Authorization Bearer TokenBearer\s+[a-zA-Z0-9\-._~+/]+=*
🛢️ Database URLs
31. MongoDB Connection URImongodb(\+srv)?:\/\/[^\s'"]+
32. PostgreSQL URIpostgres(?:ql)?:\/\/[^\s'"]+
33. MySQL URImysql:\/\/[^\s'"]+
34. Redis URIredis:\/\/[^\s'"]+
35. Elasticsearch URIelasticsearch:\/\/[^\s'"]+
36. Supabase DB Keysupabase\.co\/[a-z0-9]{15,}
37. Firebase URLhttps:\/\/[a-z0-9-]+\.firebaseio\.com
38. JDBC URLjdbc:\w+:\/\/[^\s'"]+
39. AWS RDS Hostname[a-z0-9-]+\.rds\.amazonaws\.com
40. Cloud SQL URI (GCP)googleapis\.com\/sql\/v1beta4\/projects\/
🛰️ Other Service Credentials
41. Algolia API Key(?i)(algolia|application)_?key['"\s:=]+[a-zA-Z0-9]{10,}
42. Firebase API KeyfirebaseConfig\s*=\s*{[^}]*apiKey\s*:\s*['"][^'"]+['"]
43. Cloudinary URLcloudinary:\/\/[0-9]{15}:[a-zA-Z0-9]+@[a-zA-Z]+
44. Sentry DSNhttps:\/\/[a-zA-Z0-9]+@[a-z]+\.ingest\.sentry\.io\/\d+
45. Netlify TokennetlifyAuthToken\s*=\s*['"][a-z0-9]{40}['"]
46. GitHub OAuth App Secret[a-f0-9]{40}
47. Segment API Key(?i)segment(.{0,20})?key['"\s:=]+[a-zA-Z0-9]{10,}
48. Intercom Access Token(?i)intercom(.{0,20})?token['"\s:=]+[a-zA-Z0-9-_]{20,}
49. Amplitude API KeyapiKey['"]?\s*:\s*['"][a-z0-9\-]{32,64}['"]
50. Plaid Client Secretplaid(.{0,20})?(client)?secret['"\s:=]+[a-z0-9-_]{30,}
📦 Container & Deployment Secrets
51. Docker Hub Password(?i)docker(.{0,20})?password['"\s:=]+[^\s'"]{8,}
52. AWS IAM Role ARNarn:aws:iam::[0-9]{12}:role\/[A-Za-z0-9_+=,.@\-_/]+
53. AWS S3 Bucket URLs3:\/\/[a-z0-9\-\.]{3,63}
54. Kubernetes Secret Name(?i)secretName:\s*['"]?[a-z0-9\-]+['"]?
55. Helm Secret Value(?i)secret\s*:\s*['"][^'"]+['"]
56. GitHub Actions Secret Referencesecrets\.[A-Z0-9_]+
57. GitHub Actions Encrypted Valueencrypted_value:\s*['"][a-zA-Z0-9+/=]{10,}['"]
58. K8s Service Account TokeneyJhbGciOiJSUzI1NiIsImtpZCI6
59. Vault Tokens\.[a-zA-Z0-9]{8,}
60. Hashicorp Vault URLhttps:\/\/vault\.[a-z0-9\-_\.]+\.com
🧰 DevOps & CI/CD Credentials
61. CircleCI Tokencircle-token=[a-z0-9]{40}
62. Travis CI Token(?i)travis(.{0,20})?token['"\s:=]+[a-z0-9]{30,}
63. Jenkins Crumb TokenJenkins-Crumb:\s*[a-z0-9]{30,}
64. Azure DevOps Token[a-z0-9]{52}
65. GitHub Personal Access Tokenghp_[a-zA-Z0-9]{36}
66. GitHub Fine-Grained Tokengithub_pat_[0-9a-zA-Z_]{20,}
67. Bitbucket OAuth Keybitbucket(.{0,20})?key['"\s:=]+[a-zA-Z0-9]{20,}
68. Bitbucket OAuth Secretbitbucket(.{0,20})?secret['"\s:=]+[a-zA-Z0-9]{20,}
69. GitLab Runner Tokenglrt-[a-zA-Z0-9_-]{20}
70. Netlify Access TokennetlifyAuthToken\s*=\s*['"][a-z0-9]{40}['"]
🛠️ SDKs & Tooling Keys
71. Bugsnag API Key[a-f0-9]{32}
72. Datadog API Key[a-z0-9]{32}
73. Loggly Token[a-z0-9]{30}-[a-z0-9]{10}
74. New Relic KeyNRII-[a-zA-Z0-9]{20,}
75. Mixpanel Token(?i)mixpanel(.{0,20})?token['"\s:=]+[a-z0-9]{32}
76. Heap Analytics App IDheapSettings\.appId\s*=\s*['"][a-z0-9]{8,12}['"]
77. Keen IO Project IDprojectId['"]?\s*:\s*['"][a-f0-9]{24}['"]
78. Keen IO Write KeywriteKey['"]?\s*:\s*['"][a-zA-Z0-9]{64}['"]
79. Snyk Tokensnyk_token\s*=\s*[a-f0-9\-]{36}
80. Rollbar Access Tokenaccess_token['"]?\s*:\s*['"][a-z0-9]{32}['"]
🎮 App & Game APIs
81. Twitch API Key(?i)twitch(.{0,20})?key['"\s:=]+[a-zA-Z0-9]{20,}
82. Discord Bot Token[MN][A-Za-z\d]{23}\.[\w-]{6}\.[\w-]{27}
83. Discord Webhook URLhttps:\/\/discord(?:app)?\.com\/api\/webhooks\/[0-9]+\/[a-zA-Z0-9_-]+
84. Steam Web API Key(?i)steam(.{0,20})?key['"\s:=]+[a-zA-Z0-9]{32}
85. Riot Games API KeyRGAPI-[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}
🌐 URL Leaks & Internal Endpoints
86. Private IP (Internal)\b(10\.\d{1,3}|\b192\.168|\b172\.(1[6-9]|2\d|3[01]))\.\d{1,3}\.\d{1,3}
87. Localhost Referencelocalhost:[0-9]{2,5}
88. Dev/Stage URL(dev|staging|test)\.[a-z0-9.-]+\.(com|net|io)
89. Internal Subdomain URLhttps?:\/\/[a-z0-9.-]+\.internal\.[a-z]{2,}
90. Preprod URLshttps:\/\/preprod\.[a-z0-9-]+\.[a-z]{2,}
🧪 Miscellaneous & Generic
91. Private Key Block-----BEGIN (RSA|DSA|EC|OPENSSH)? PRIVATE KEY-----
92. PEM File Content-----BEGIN CERTIFICATE-----
93. PGP Private Key Block-----BEGIN PGP PRIVATE KEY BLOCK-----
94. Base64 High Entropy String['\"][A-Za-z0-9+\/]{40,}={0,2}['\"]
95. API Key Generic Detector(?i)(apikey|api_key|secret|token)['"\s:=]+[a-zA-Z0-9\-._]{8,}
96. Bearer Token Generic(?i)authorization:\s*Bearer\s+[a-zA-Z0-9\-._~+/]+=*
97. Session ID(?i)(sessionid|session_id)['"\s:=]+[a-zA-Z0-9]{10,}
98. Cookie Name Generic(?i)set-cookie:\s*[a-zA-Z0-9_-]+=
99. CSRF Token(?i)csrf(token)?['"\s:=]+[a-zA-Z0-9-_]{8,}
100. JWT in Local StoragelocalStorage\.setItem\(['"]token['"],\s*['"]eyJ[a-zA-Z0-9-_]+\.[a-zA-Z0-9-_]+\.[a-zA-Z0-9-_]+['"]\)
✅ Final Words
Security researchers often stumble upon gold hidden in plain sight — especially in exposed JavaScript files. These 100 regex patterns can help uncover secrets quickly and systematically during bug bounty, red teaming, or automated scanning.
If you don’t want the hassle of manually hunting down all these sensitive keys in JavaScript files, let Jsmon do the work for you. 🚀
Let us know what patterns you use, and we’ll keep the list growing! 🙌
Join our Discord group: https://jsmon.sh/discord-invite
Previous Post: JS Contextual API Hacking Checklist
Member discussion