Moving users from Firebase Authentication to Keycloak
Firebase Authentication keeps users in a project, with an email, a verified flag, a display name, the providers they sign in with and any custom claims you set. Keycloak keeps users in a realm, with a username, an email, first and last name, attributes, groups and credentials. The two line up well, apart from the password.
This converter reads the JSON file that firebase auth:export writes and turns it into a Keycloak partial import or realm import file. It runs in your browser. It leaves out every password hash and salt, marks password users with the Update Password required action, and lists what it could not carry over.
For the whole move, with the plan, the user emails and the cut-over, see moving from Firebase.
Exporting users from Firebase
The Firebase CLI exports every user of a project to a file. Use JSON, which keeps nested data such as provider lists and second factors; the CSV format flattens them into fixed columns.
firebase auth:export users.json --format=json --project <project-id>Each user in the file can have these fields: localId, email, emailVerified, passwordHash, salt, displayName, photoUrl, createdAt, lastSignedInAt, phoneNumber, disabled, customAttributes, mfaInfo and providerUserInfo, the list of linked providers with their own ids.
The export holds password hashes for users whose passwords use Firebase’s default scrypt. Treat the file as a secret even though this tool leaves the hashes out of its output.
Why passwords do not move
Firebase hashes passwords with a modified version of scrypt, which is the default for Firebase projects. Verifying one of those hashes needs the project’s hash parameters too: the signer key, the salt separator, the rounds and the memory cost, which the Firebase console shows under the users list.
Keycloak ships hash providers for Argon2 and the PBKDF2 family, and none for Firebase’s scrypt. A Firebase hash imported as a Keycloak credential would never match. RealmDeploy clusters run the stock Keycloak image without custom providers, so a custom scrypt provider cannot be added today. We are evaluating one; until it exists on our clusters, Firebase password users set a new password by email link after the move.
The tool counts how many records held a hash, so you can see what was left out, and writes none of them.
What the tool does with each field
| Firebase field | Keycloak user | Notes |
|---|---|---|
email | email, in lower case | Also the username by default |
emailVerified | emailVerified | Kept as it was |
displayName | firstName, lastName | Split at the first space |
disabled | enabled: false | Or left out, if you choose |
createdAt | createdTimestamp | Already in milliseconds |
localId | The firebase_uid attribute | Keep it to match app data |
customAttributes | User attributes | The JSON of your custom claims |
| The claim you name for groups | groups, as paths | Such as groups or roles |
phoneNumber, photoUrl | phoneNumber, picture attributes | Keycloak has no built-in fields for them |
providerUserInfo | Who sets a password, who re-links | Not written to the file |
Left out, and listed in the result: passwordHash and salt, mfaInfo, and lastSignedInAt.
Display names
Firebase has one display name; Keycloak has a first and a last name, and its default user profile asks for both. The tool takes the first word as the first name and the rest as the last name. That suits many names and not all of them. Check the result for names written family name first, or with one word only. A user with an empty last name is asked to complete the profile at the next sign-in, which is a fine outcome too.
Custom claims, attributes and groups
Custom claims are a JSON object you set with the Admin SDK, such as {"groups": ["staff"], "tier": "gold"}. The claim you name becomes Keycloak groups, and the others become attributes. Nested objects become dotted attribute names, and lists stay lists.
Apps that read a claim from the Firebase ID token will need the same claim in the Keycloak token. Add the attribute to the realm’s user profile, then a user attribute mapper on the client scope, so the token carries it under the same name.
Social and phone sign-in
A user whose providers include google.com, apple.com or another social provider gets no password step. Once you set up that identity provider in Keycloak, their first sign-in finds the account by email and asks them to confirm the link.
A phone-only user has no email, so no set-password link can reach them. Keycloak has no SMS sign-in out of the box; the tool lists these users as warnings so you can decide what to do with them.
The output
{
"users": [
{
"username": "[email protected]",
"email": "[email protected]",
"emailVerified": true,
"firstName": "Sample",
"lastName": "One",
"enabled": true,
"createdTimestamp": 1709370900000,
"attributes": {
"tier": ["gold"],
"firebase_uid": ["sampleUid001"]
},
"groups": ["/staff"],
"requiredActions": ["UPDATE_PASSWORD"]
}
]
}With “Create the groups in the same file” on, the file also lists the groups, so a partial import creates them before it adds the users. The preview shows 20 users; the saved file has all of them.
Importing and sending the set-password emails
- Add your attributes to the realm’s user profile.
- Configure the realm’s SMTP connection and send a test email.
- Set up the social identity providers your users had in Firebase.
- Import the file into a staging realm with Partial import, and compare counts with the summary.
- Test a password user and a social user end to end.
- Import into production at cut-over and send the set-password emails.
Keycloak sends the set-password email when an admin uses Credential reset on a user, or when a script calls the execute-actions-email endpoint with ["UPDATE_PASSWORD"]. The link opens Keycloak’s Update Password page, and it lasts as long as you choose. If the realm allows Forgot password on the sign-in page, users who miss the email can ask for a new link themselves.
Tell users before the email arrives, so they trust it. The migration email templates give you an announcement, an email for the day and a reminder.
Switching your apps from Firebase tokens
Users are half of a Firebase move; the apps are the other half. Firebase apps sign in through the Firebase Auth SDK and send a Firebase ID token to your backend, which verifies it with the Admin SDK. After the move, apps sign in with OpenID Connect and send a Keycloak access token, which your backend verifies against the realm’s keys.
| Today | After the move |
|---|---|
| Firebase Auth SDK in a web app | An OpenID Connect library, the authorization code flow with PKCE |
| Firebase Auth SDK in a mobile app | An AppAuth library, the system browser, and a custom scheme or app link as redirect URI |
verifyIdToken in your backend | JWT verification against /realms/<realm>/protocol/openid-connect/certs |
request.auth in security rules | Rules that read your own backend’s checks, since Firebase rules trust Firebase tokens |
uid as the key of user data | firebase_uid attribute mapped into the token, or a lookup on first sign-in |
Mobile apps set the pace. A new release has to reach users before the cut-over, and users who do not update keep the old sign-in. Plan a release that can sign in with Keycloak, ship it ahead of the date, and keep Firebase Authentication running until most users have it.
If Firestore or Realtime Database rules check request.auth, they trust only Firebase tokens. Moving away from Firebase Authentication means those reads and writes go through your own backend, or through custom tokens you mint after checking a Keycloak token. Decide which before you set a date.
Checking the result
After the dry run import, compare three numbers with the summary: users in the realm, users with the Update Password action (under Users, filter by required action in the admin API), and users in each group. Then open three or four users and compare their attributes with the Firebase console.
Sign in as a test user from each app and read the token with the JWT decoder. The claims your app reads must be there under the same names.
Mistakes to avoid
- Exporting as CSV and losing the provider list, which tells password users from social ones.
- Importing
passwordHashas a Keycloak credential. It will not verify. - Forgetting that Firebase allows one account per email only when the project is set that way. Duplicate emails are kept once and listed.
- Leaving apps on Firebase ID tokens. Each app must switch to Keycloak’s issuer and its keys.
- Keeping
users.jsonafter the move. It holds hashes; delete every copy.
Where we come in
On Premium and Enterprise, our team does the move with you within the plan’s 10 service hours a month. On Starter, you use these tools and guides, with written support for questions. Very large moves are scoped as Custom through the contact form. The readiness checklist has every step for a Firebase move.