What a realm export is
A realm export is a JSON file that describes one Keycloak realm: its settings, clients, roles, groups, client scopes, authentication flows, identity providers, user federation, keys and, if you ask for them, its users. Keycloak can import the same file to rebuild the realm on another server.
Because the file holds the whole configuration in one place, it is the best starting point for any question about a realm. How many clients does it have? Which ones still use the implicit flow? Does it depend on a theme or an authenticator that is not part of Keycloak? Reading the raw JSON answers those questions, but a real export runs to thousands of lines. This tool reads it for you and lists what matters.
Why it matters before a change
Most trouble with Keycloak migrations and upgrades comes from things nobody remembered: a custom login theme, an authenticator someone deployed years ago, an LDAP provider that only one realm uses, or a client with a wildcard redirect URI. They work until the day the realm moves to a server that does not have them.
A quick inventory before the change turns those surprises into a list. You can decide what to bring along, what to replace and what to remove, and you can size the work from real numbers instead of guesses.
How to export a realm in Keycloak 26
There are two ways to get the file. Each gives you something different.
kc.sh export
The export command of the Keycloak distribution writes the full realm, including users if you ask for them. Run it against the same database as the server, ideally while the server is stopped, so nothing changes during the export.
bin/kc.sh export --realm acme --file /tmp/acme-realm.json --users realm_fileWith --dir instead of --file, Keycloak writes the realm and its users into separate files in that folder. The --users option decides where users go: realm_file, same_file, different_files or skip.
Partial export in the admin console
Under Realm settings, the Action menu has Partial export. It can include groups and roles, and clients, but never users. It replaces secrets with **********, so the file is safer to pass around but cannot restore those secrets on import.
What this tool does
Paste the JSON or open the file. The tool parses it in your browser and shows:
- Counts of clients, realm roles, client roles, groups (including subgroups), users in the file, identity providers, user federation providers and custom authentication flows.
- The realm settings people ask about most:
sslRequired, registration, brute force detection, the password policy, token and session lifespans, whether events are saved, and the SMTP host. - Custom code the realm depends on: login, account, admin or email themes that Keycloak does not ship, authenticators in flows that are not in its list of built-in ones, and component types it does not recognize.
- Settings worth a second look, such as wildcard redirect URIs,
*web origins, the implicit flow, password grants, public clients without PKCE, secrets left in the file and users with stored credentials.
Built-in objects are left out of the counts: the account, account-console, admin-cli, broker, realm-management and security-admin-console clients, and the default realm roles. What remains is your own configuration.
What it does not do
The analyzer reads the file. It does not connect to your server, so it cannot see anything the export left out, such as users written to separate files or the state of a running cluster.
Its list of built-in authenticators covers the common ones, not every authenticator in every version. An authenticator it does not know is marked as possibly custom, so check each one against your server before you plan around it. The same goes for component types.
It also does not judge whether a setting is right for you. Registration being on, for example, is a choice, not a fault. The findings are prompts for review.
How to use it
- Export the realm with
kc.sh exportor the admin console. - Open the file with Open a file, or paste its contents. A made-up sample realm is filled in to show the output.
- Read the counts first, to see the size of the realm.
- Check the custom code notice. Each item there needs a plan before a move.
- Work through the findings and note the ones you want to fix.
- If you will share the file, run it through the realm export sanitizer first.
Where it helps
Planning a migration
Moving a realm to another server or another hosting setup starts with an inventory. The counts tell you how much there is to test, and the custom code list tells you what the new server must offer. If you plan to move to managed hosting, this list is exactly what to check first, because a managed service may run the stock Keycloak image. Ours does: see how we migrate realms.
Before an upgrade
Custom authenticators and themes are the parts most likely to break across Keycloak versions, since they depend on internal APIs and templates. Knowing which ones a realm uses tells you what to test on a staging copy before you upgrade.
Security review
The findings cover the settings auditors ask about first: TLS requirement, brute force detection, password policy, wildcard redirects, open CORS and legacy flows. Running every realm through the tool gives a quick, repeatable first pass.
Taking over a realm
When you inherit a Keycloak setup, an export plus this summary is a fast way to learn what you are responsible for, without clicking through every tab of the admin console.
Reading the findings
| Finding | Why it matters | Usual fix |
|---|---|---|
sslRequired is none | The realm accepts sign-ins over plain HTTP. | Set it to external or all. |
Redirect URI * | Codes and tokens can be sent to any address. | List the app’s real redirect URIs. |
Web origins * | Any site may call the token endpoint from a browser. | Use + or list origins. |
| Implicit flow on | Tokens travel in the URL fragment. | Use the code flow with PKCE. |
| Direct access grants on | The app handles user passwords itself. | Turn off unless a legacy app needs it. |
| Public client without PKCE | An intercepted code can be redeemed. | Require S256 PKCE on the client. |
| Brute force detection off | Password guessing is not slowed. | Turn it on under Security defenses. |
Use the web origins helper and the OIDC client generator to work out safer client settings, and the password policy builder for the policy.
Common problems with export files
The file has no users
The partial export never includes users, and kc.sh export --dir writes them to separate files unless you pass --users realm_file or --users same_file. Open one of the users files to count them, or export again with a different option.
The file is a list of realms
Some exports hold several realms in a JSON array. The tool shows the first one and says how many there are. Export one realm at a time to analyze each.
The JSON does not parse
Exports can be large, and copying from a terminal sometimes cuts them off. Open the file with Open a file instead of pasting, and check that it ends with a closing brace.
Security notes
A full export is sensitive. It can contain client secrets, the realm’s private signing keys, identity provider secrets, the LDAP bind password, the SMTP password and every user’s password hash and personal data.
This page reads the file with the browser’s FileReader and sends nothing anywhere. The risk is the file itself: keep it out of tickets, chat and shared drives, and delete local copies when you are done. To share one, remove secrets and users first.
Best practices
- Export from a quiet server, so the snapshot is consistent.
- Keep a sanitized export of each realm under version control, and compare it after changes with the realm export diff.
- Write down every custom theme and provider the analyzer finds, with its owner and source code location.
- Fix wildcard redirect URIs and open web origins first; they are the findings with the largest impact.
- Re-run the analysis after a cleanup, to confirm the findings are gone.