Skip to content

Azure AD B2C to Keycloak user converter

Turn Microsoft Graph user JSON from Azure AD B2C or Entra External ID into a Keycloak import file: sign-in names, emails, extension attributes and groups.

Runs in your browser. Nothing you paste is sent to us.

Azure AD B2C export

The JSON of GET /users from Microsoft Graph with identities selected, from Azure AD B2C or Entra External ID. Made-up users are filled in. It stays in your browser.

Falls back to the other when a user has none. Usernames are written in lower case.

memberOf, when you ask Graph to expand it: group names become group paths. Leave it empty for none.

Output

Keycloak users

3 users 2 set a new password 1 sign in with a provider

Records read
3
Users in the file
3
Left out
0
Set a new password by email link
2Marked with the Update Password required action
Social or enterprise sign-in only
1Re-link by email at their first sign-in
Disabled in the source
1
In groups
0
Attributes
2b2c_object_id, loyaltyNumber
Password hashes left out
0Keycloak cannot verify them, so the file never holds them
1 to check
  • Record 3 (00000000-0000-4000-8000-0000000000a3): has no email, so a set-password link cannot reach them.
JSON
{
  "users": [
    {
      "username": "[email protected]",
      "email": "[email protected]",
      "emailVerified": false,
      "firstName": "Sample",
      "lastName": "One",
      "enabled": true,
      "createdTimestamp": 1709370900000,
      "attributes": {
        "loyaltyNumber": [
          "1001"
        ],
        "b2c_object_id": [
          "00000000-0000-4000-8000-0000000000a1"
        ]
      },
      "requiredActions": [
        "UPDATE_PASSWORD"
      ]
    },
    {
      "username": "[email protected]",
      "email": "[email protected]",
      "emailVerified": false,
      "firstName": "Sample",
      "lastName": "Two",
      "enabled": true,
      "attributes": {
        "b2c_object_id": [
          "00000000-0000-4000-8000-0000000000a2"
        ]
      }
    },
    {
      "username": "user-003",
      "emailVerified": false,
      "firstName": "Sample",
      "lastName": "Three",
      "enabled": false,
      "attributes": {
        "b2c_object_id": [
          "00000000-0000-4000-8000-0000000000a3"
        ]
      },
      "requiredActions": [
        "UPDATE_PASSWORD"
      ]
    }
  ]
}
Read but not carried over
  • passwordProfile: Graph never returns a password.
  • identities: Used for the sign-in name and to spot federated users, then left out.
  • userPrincipalName: Kept only as the b2c_upn attribute when there is no other name.
  • @odata.*, signInActivity: Metadata and history do not move.
In the admin console: Realm settings, Action, Partial import. Choose Skip or Fail for users that already exist. Keycloak keeps only attributes its user profile declares, unless the realm allows unmanaged attributes: add them to the user profile first.

How to use it

  1. List users with Microsoft Graph, selecting identities and your extension attributes.
  2. Paste the JSON or open the file.
  3. Name memberOf if you expanded it, for groups.
  4. Save the import file and test it on a staging realm.

What to know

Graph never returns a user’s password, and B2C has no export of password hashes. Local accounts set a new password by email link after the move.

The sign-in email or username comes from identities. Extension attributes lose their extension_<app id>_ prefix and keep their own name.

Federated identities, such as Google or Facebook, get no password step. They re-link by email at their first sign-in.

Moving users from Azure AD B2C or Entra External ID to Keycloak

Microsoft stopped selling Azure AD B2C to new customers on May 1, 2025, and points existing tenants to Microsoft Entra External ID. Some teams follow that path; others take the moment to move to Keycloak. Either way, users live in the tenant’s directory and come out through Microsoft Graph.

This converter reads the users JSON Graph returns and writes a Keycloak partial import or realm import file. It reads the sign-in names from identities, strips the extension_<app id>_ prefix from custom attributes, and gives local accounts a set-password step. It runs in your browser.

For the whole move, see moving from Azure AD B2C.

Getting users out with Microsoft Graph

List users with Graph’s users endpoint. Select the properties you need, because identities and extension attributes are not in the default set. Graph returns pages of users with an @odata.nextLink; follow it until it is gone, and put the users of every page into one value array.

One page of users (replace the extension names with your own)
GET https://graph.microsoft.com/v1.0/users?$select=id,displayName,givenName,surname,mail,otherMails,identities,accountEnabled,createdDateTime,extension_<app-id>_loyaltyNumber&$top=999

In B2C, custom attributes are extension properties on the b2c-extensions-app application. Graph names them extension_<client id without hyphens>_<name>, such as extension_831374b3bd5041bfaa54263ec9e050fc_loyaltyNumber. The tool keeps the part after the id as the Keycloak attribute name.

For groups, add memberOf with an expand, or list group members separately. The tool reads memberOf as a list of objects and uses each displayName as a group name.

Why passwords do not move

Graph lets you set a user’s password when you create or update the user, and never returns it. The B2C attribute reference lists password as an attribute you can write, not one you can read. There is no export of password hashes. Microsoft’s own guidance for moving B2C users to External ID keeps passwords only by checking them against B2C at sign-in, just in time, not by copying hashes.

A just-in-time check needs the old system running beside the new one, and code in the new one’s sign-in path. RealmDeploy clusters run stock Keycloak without custom providers, so we do not offer that. Local B2C accounts set a new password by email link after the move: the tool gives them the UPDATE_PASSWORD required action, and Keycloak sends the link through the realm’s SMTP connection.

Federated identities, such as Google, Facebook or a company’s identity provider, have signInType: federated. They get no password step and link to their account by email at their first sign-in through the same provider in Keycloak.

What the tool does with each field

Graph propertyKeycloak userNotes
identities with emailAddressemail, and the username by defaultThe sign-in email of a local account
identities with userNameusername when you choose the idFor username sign-in
mail, then otherMailsemailWhen there is no sign-in email
givenName, surnamefirstName, lastNameFrom displayName when both are empty
accountEnabledenabled
createdDateTimecreatedTimestamp
idThe b2c_object_id attributeThe object id your apps saw as oid
extension_<id>_<name>The <name> attributePrefix removed
city, country, jobTitle and similarAttributes of the same name
memberOfgroups, when you name itDisplay names as paths

Read and left out: passwordProfile, identities after use, userPrincipalName (kept as b2c_upn only when a user has no other name), and Graph metadata such as @odata fields.

B2C has no per-user verified flag in Graph. Local accounts that sign in with an email usually proved it during sign-up, depending on your user flow; tick “Mark every email as verified” if that holds for your tenant.

The output

Sample output for one made-up user
{
  "users": [
    {
      "username": "[email protected]",
      "email": "[email protected]",
      "emailVerified": false,
      "firstName": "Sample",
      "lastName": "One",
      "enabled": true,
      "createdTimestamp": 1709370900000,
      "attributes": {
        "loyaltyNumber": ["1001"],
        "b2c_object_id": ["00000000-0000-4000-8000-0000000000a1"]
      },
      "requiredActions": ["UPDATE_PASSWORD"]
    }
  ]
}

The preview shows 20 users; the saved file has every user.

User flows, custom policies and MFA

B2C user flows and custom policies (the Identity Experience Framework XML) do not move. Map each to Keycloak: sign-up and sign-in become the realm’s browser flow and registration settings, profile editing becomes the account console or required actions, and claims you shaped in a policy become protocol mappers on a client scope. REST API calls from custom policies have no direct counterpart in stock Keycloak, so plan where that logic lives after the move.

MFA does not move either. Graph returns the secret of a software OATH (TOTP) method as null, always. Users who used an authenticator app set it up again at their first sign-in; SMS and phone call codes have no built-in Keycloak counterpart, so decide on TOTP or passkeys before the move.

One file from many pages

Graph returns users in pages and puts the address of the next page in @odata.nextLink. Follow it until a page has none, and join the value arrays. With the Microsoft Graph PowerShell module, Get-MgUser -All does the paging for you; with plain HTTP, a short loop does.

All users into one file (a sketch with curl and jq; the token needs User.Read.All)
URL='https://graph.microsoft.com/v1.0/users?$select=id,displayName,givenName,surname,mail,otherMails,identities,accountEnabled,createdDateTime&$top=999'
: > pages.ndjson
while [ -n "$URL" ] && [ "$URL" != "null" ]; do
  curl -s "$URL" -H "Authorization: Bearer <token>" > page.json
  jq -c '.value[]' page.json >> pages.ndjson
  URL=$(jq -r '."@odata.nextLink"' page.json)
done
jq -s '{value: .}' pages.ndjson > users.json

B2C tenants can hold many users, and Graph throttles requests per app and tenant. If a page answers with status 429, wait for the number of seconds in its Retry-After header and ask again; the loop above stops at the first error, so check that the last page really had no next link.

Use an app registration made for the move, with read permissions only, and remove its secret when the export is done.

Add your extension attributes to $select by their full name. Graph returns nothing for an extension you do not name, so a missing attribute in the output usually means a missing name in the query.

Keycloak or Entra External ID

Microsoft offers its own path: Entra External ID, with a documented migration from B2C and a just-in-time password migration that keeps passwords. If keeping every password matters more than anything else, or you want to stay inside Microsoft’s identity products, that path fits better.

Both paths need the same groundwork: an inventory of apps and identity providers, a plan for custom policy logic, and a dry run before users notice anything. The export and the converter here work the same whichever you choose, because External ID reads users from Graph too.

Keycloak fits when you want an open-source server you can take anywhere, standard OpenID Connect and SAML without a vendor’s policy language, and a cluster of your own. The cost of that choice in a B2C move is the password: users set a new one by email link.

What your users see

Local accounts get one email from Keycloak with a link to set a new password. Users who signed in with Google, Facebook or a company’s provider see the same provider button on Keycloak’s sign-in page and confirm the link to their account once. Everyone signs in again, because B2C sessions and refresh tokens do not carry over.

The sign-in page looks different. Clusters run Keycloak’s own themes, and custom themes are not supported yet, so the branded B2C pages you built with HTML templates do not come along. Tell users in your announcement that the page will look different and where its address will be.

Mistakes to avoid

  • Listing users without $select=identities, and getting no sign-in names.
  • Using userPrincipalName as the username. In B2C it is a generated value, not what users type.
  • Stopping at the first page. Follow @odata.nextLink to the end.
  • Forgetting that apps keyed on the B2C object id (oid) see a new subject in Keycloak tokens. Keep b2c_object_id and map it.
  • Moving before the realm’s SMTP connection is tested, so set-password emails fail.

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. Very large tenants are scoped as Custom through the contact form. The readiness checklist has the steps, and the email templates help you tell users.

Questions

Frequently asked questions

Can Azure AD B2C users keep their passwords in Keycloak?

No. Graph never returns passwords and B2C has no hash export, so local accounts set a new password by email link.

Does this work for Microsoft Entra External ID?

Yes. External ID users come from the same Graph users endpoint, with identities and extension attributes in the same shape.

Why are my custom attributes missing?

Graph returns extension attributes only when you name them in $select. Add each one, then declare it in the realm’s user profile.

What happens to users who sign in with Google or Facebook?

They are federated identities: no password step, and a link to their account by email at their first sign-in.

Do authenticator apps move?

No. Graph always returns the TOTP secret as null, so users set up their authenticator again.

Is Azure AD B2C still sold?

Not to new customers since May 1, 2025, according to Microsoft. Existing tenants keep working, and Microsoft points them to External ID.

Which Graph permission do I need?

Reading every user needs User.Read.All, granted by an admin of the tenant. Expanding memberOf for groups needs a group or directory read permission as well.

Why does the username come from identities and not userPrincipalName?

In B2C, userPrincipalName is generated and users never type it. The sign-in name in identities is what they use, so it makes the better Keycloak username.

Is my data uploaded?

No. The tool runs in your browser, and the saved file is made on your computer.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.