LeakPatrol › Guides

How to check if your API key is exposed on your website

By Paweera, Site Reliability Engineer · Updated 18 October 2026

If a secret API key is in your website's JavaScript, anyone can copy it in seconds, and bots scan new sites for exactly that. Here's how to check your own site, what the common key formats look like, and what to do if you find one.

Check your site in two minutes

  1. Open your live website in Chrome, Edge or Firefox.
  2. Open DevTools (F12, or Cmd+Option+I on a Mac) and go to Sources.
  3. Press Ctrl+Shift+F (Cmd+Option+F on a Mac) to search across all files.
  4. Search for each of the prefixes below. A secret key should never appear.

What leaked keys look like

ServiceSecret key starts withRisk
OpenAIsk-proj-, sk-Usage billed to you
Anthropicsk-ant-Usage billed to you
Stripesk_live_, rk_live_Refunds, payouts, customer data
AWSAKIA, ASIAWhatever the key can reach
Supabaseservice_role JWT, sb_secret_Your whole database
GitHubghp_, github_pat_Your repositories
GoogleAIzaDepends on restrictions

Some keys are meant to be public: Stripe publishable keys (pk_live_) and the Supabase anon key are fine in the browser.

Why keys end up in the frontend

In apps built with Vite, Next.js or Create React App, environment variables starting with VITE_, NEXT_PUBLIC_ or REACT_APP_ are bundled into the JavaScript every visitor downloads. AI coding tools often use these prefixes to make a feature work quickly. Other common leaks are a public .env file (try opening yoursite.com/.env) and public source maps.

If you find a leaked key

  1. Rotate it now in the provider's dashboard. Deleting it from your code is not enough: it's already been downloaded.
  2. Move the call to a server, such as a serverless function or Supabase Edge Function, that reads the key from a secret.
  3. Set a spend limit for AI providers so a future leak can't run up an unlimited bill.
  4. Check the provider's usage logs for anything you don't recognise.

LeakPatrol does this check automatically: paste your site's address and it searches every JavaScript file it loads for more than 10 kinds of secret key, plus public .env files, .git folders and source maps. It's free and read-only, and any key it finds is masked.

Check your app in a minute

Free, read-only, no sign-up. Every problem comes with a plain-English fix and a prompt for your AI tool.

Scan your app free

Questions

How do I know if my API key is exposed?

Open your live website, go to DevTools, search all JavaScript files for key prefixes such as sk-, sk_live_, AKIA and service_role, or use a free read-only scanner like LeakPatrol.

Is it safe to put an API key in frontend JavaScript?

Only public keys such as Stripe publishable keys or the Supabase anon key. Secret keys must stay on a server, because anything in frontend JavaScript can be read by every visitor.

What should I do if my OpenAI API key was exposed?

Revoke it in the OpenAI dashboard immediately, create a new one, move OpenAI calls to a server-side function, and set a monthly spend limit.

More guides