Supabase key checker: may this key sit in the browser?
Paste a Supabase key, a .env file or code and see right away which keys may sit in browser code and which must stay on the server. Nothing is sent.
Runs in your browser. Nothing you enter is sent anywhere.
Recognises Supabase, Stripe, OpenAI, Anthropic and GitHub keys.
Which Supabase keys may be public?
Supabase gives every project two kinds of keys: a public one for code you ship to users and a secret one for code only you control. Each exists in an older JWT format and a newer format.
| Key | Looks like | In browser code? | Why |
|---|---|---|---|
| anon (legacy) | eyJ…, role anon inside | Yes | Only reaches what row level security allows |
| publishable | sb_publishable_… | Yes | Same rights as the anon key |
| service_role (legacy) | eyJ…, role service_role inside | Never | Bypasses row level security |
| secret | sb_secret_… | Never | Bypasses row level security |
Supabase’s own docs put it plainly: anything you ship gets the publishable key, anything you control gets the secret key, and a secret key must never reach a browser, a shipped app or source control.
Why is a public key not a free pass?
Everyone who opens your app can read the anon or publishable key. That is fine, because the key alone grants nothing: what it can read and change is decided by row level security on each table. If one table has RLS turned off, or a policy that says using (true), anyone with the public key can read that table directly, without your app.
So the real question behind “is my anon key safe?” is “does every table have the right policies?”. Our RLS policy builder writes and tests them for you, and the fix pages for a table without RLS and policies with using (true) show how to find the gaps.
How does a secret end up in the browser?
Build tools copy some environment variables into the code your visitors download. In Vite, the build tool behind Lovable apps, that is every variable starting with VITE_; in Next.js it is NEXT_PUBLIC_. The value is then readable by anyone who opens the browser’s developer tools.
The usual way it happens in AI-built apps: a feature needs admin rights, the AI adds the service role key as VITE_SUPABASE_SERVICE_ROLE_KEY so the browser code can use it, and the app works. The checker marks exactly this case as critical. The fix pages for a secret in a VITE_ variable and the service_role key in the frontend walk through moving that code to the server.
What to do when a secret key was exposed
Move the code that needs it to the server
Put the privileged part into a Supabase Edge Function or a server route that checks who is calling, and keep the key in that function’s secrets.
Replace the key
Create a new secret key and delete the old one, or rotate the legacy key. Removing the key from the code is not enough: it stays in old builds and in your Git history.
Check what was reachable
Look at your database logs for requests you don’t recognise. Our guide to a leaked service role key covers this step by step.
Find every place where the Supabase service role or secret key, or any other secret key (Stripe secret key, OpenAI or Anthropic key), is used in browser code or stored in a VITE_ or NEXT_PUBLIC_ environment variable. Move each of those operations into a Supabase Edge Function that verifies the caller’s JWT and checks that the user may do this action. Keep the key only in the Edge Function’s secrets. In the browser, call the function with the normal Supabase client. Remove the VITE_ / NEXT_PUBLIC_ variables that held secrets. Tell me which keys I must rotate afterwards.
What the checker does and doesn’t do
- It recognises keys by their format: Supabase, Stripe, OpenAI, Anthropic and GitHub. Other secrets, such as database passwords or keys from other providers, are not flagged.
- It reads what is inside a Supabase JWT (role, project, expiry) but does not verify the signature: that would need your project’s JWT secret. It also can’t tell whether a key still works.
- It checks the text you paste, not your live site or your repository.
Frequently asked questions
Is it safe to paste my key here?
The checker runs entirely in your browser: it reads the text in memory and makes no network request, which you can confirm in your browser’s network tab. Still, treat a secret key that has been in a chat, a screenshot or a public repository as leaked and replace it.
Is the Supabase anon key a secret?
No. The anon key and its successor, the publishable key, are made to be shipped in browser and mobile code. They only reach what your row level security policies allow, so the protection comes from those policies, not from hiding the key.
What is the difference between the anon key and the publishable key?
Both are public keys with the same rights. The anon key is the older JWT format; the publishable key (sb_publishable_…) is the newer format Supabase recommends. The same goes for service_role and the secret key (sb_secret_…): different format, same power to bypass row level security.
The checker found a user token. What is that?
A signed-in user’s access token, usually copied from the browser’s storage or a request. It is not an API key: it lets whoever holds it act as that user until it expires, which is one hour by default. Don’t put it in code and don’t share it.
Sources
- 1.Understanding API keys — Supabase Docs
- 2.Row Level Security — Supabase Docs
- 3.Env variables and modes — Vite
- 4.How to use environment variables in Next.js — Next.js Docs
- 5.User sessions — Supabase Docs
- 6.Secrets Management Cheat Sheet — OWASP
Updated
Find this in your own app
ShipRely reads your repository (read-only), proves each finding with file and line, and gives you a fix prompt to paste into your AI builder.
Run a demo audit- Read-only access to your repository
- Every finding with file and line
- Fix prompts for Lovable, Cursor, Claude Code and Bolt