Skip to content

Keycloak realm export diff

Compare two Keycloak realm exports and see which realm settings, clients, roles, groups, flows, identity providers and users were added, removed or changed.

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

Two exports

Two made-up sample realms are filled in. Paste or open yours; they stay in your browser.

Paste the JSON, or open a file. It stays in your browser.

Differences

6 differences

Realm settings 2
  • changed bruteForceProtected
    false → true
  • changed passwordPolicy
    "length(8)" → "length(12) and notUsername(undefined)"
Clients 4
  • added mobile-app
  • changed web-app › implicitFlowEnabled
    true → false
  • changed web-app › redirectUris
    + https://staging.example.com/*
  • removed legacy-portal
Text report
## Realm settings
~ bruteForceProtected: false → true
~ passwordPolicy: "length(8)" → "length(12) and notUsername(undefined)"

## Clients
+ mobile-app
~ web-app › implicitFlowEnabled: true → false
~ web-app › redirectUris: + https://staging.example.com/*
- legacy-portal

How to use it

  1. Paste or open the earlier export as A and the later one as B.
  2. Keep internal ids ignored when the exports come from different servers.
  3. Read the differences by section, with old and new values.
  4. Copy the text report for a review or a change ticket.

What to know

Comparing exports is the simplest way to see what changed between a staging realm and production, or before and after someone worked in the admin console.

The diff matches clients by client id, roles by name, groups by path and flows by alias, so it lines up the same thing across servers even though its internal id differs.

Lists of plain values, such as redirect URIs, are compared as sets: a different order is not a change.

Why compare realm exports

Keycloak keeps its configuration in a database and changes it through the admin console, the admin API and imports. That makes it easy to change and hard to review. Two realms that should match, such as staging and production, drift apart one click at a time, and nobody can say exactly when or how.

A realm export captures the whole configuration as JSON. Comparing two exports answers the questions a plain look at the console cannot: what changed since last month, which client settings differ between environments, and whether an import did what you expected.

Why a plain text diff is not enough

You can run diff on two export files, but the result is mostly noise.

  • Every object has an internal id, and ids differ on every server. Two identical clients on staging and production show as completely different.
  • Lists come out in whatever order the database returns them, so a moved role or redirect URI looks like a removal and an addition.
  • Nested objects, such as client attributes and flow executions, spread one change over many lines.

This tool compares the exports the way a person would: it matches each object by a stable name, ignores ids when asked, treats lists of plain values as sets, and reports each change as one line with the old and new value.

How objects are matched

SectionMatched by
Realm settingsField name, for every top-level setting
ClientsclientId
Realm rolesRole name
Client rolesClient id and role name
GroupsFull path, such as /staff/support
Client scopesScope name
Authentication flowsFlow alias
Identity providersAlias
Required actionsAlias
ComponentsComponent type and name
UsersUsername

Within a matched pair, the tool compares field by field and reports the path of each difference, such as web-app › implicitFlowEnabled. Objects that exist on one side only are reported as added or removed.

What this tool does and does not do

It reads two exports in your browser, compares them and lists the differences by section, with a text report you can copy into a review or a change ticket. Nothing is uploaded.

It does not tell you whether a change is right, and it does not produce an import file that applies the changes. Lists of objects inside an object, such as protocol mappers or flow executions, are compared as a whole: a change shows the full old and new value rather than each mapper. Large differences are shown in full in the text report, and the first 200 per section on the page.

How to use it

  1. Export the realm from both places, for example with kc.sh export on each server, or the admin console’s partial export.
  2. Put the older or reference export in A and the newer one in B. Two made-up sample realms are filled in to show the output.
  3. Keep Ignore internal ids on when the exports come from different servers. Turn it off only to compare two exports of the same database.
  4. Read the differences section by section. Added items are on B only, removed items on A only.
  5. Copy the text report into the review, ticket or commit message.
Text report for the sample realms
## Realm settings
~ bruteForceProtected: false → true
~ passwordPolicy: "length(8)" → "length(12) and notUsername(undefined)"

## Clients
+ mobile-app
- legacy-portal
~ web-app › implicitFlowEnabled: true → false
~ web-app › redirectUris: + https://staging.example.com/*

Getting comparable exports

A clean comparison starts with two exports made the same way. Use the same command on both sides, export one realm per file, and decide up front whether users belong in the comparison. Most configuration reviews do not need them, and leaving them out keeps the report short and free of personal data.

The same export on staging and on production (realm acme)
# on each server, against its own database
bin/kc.sh export --realm acme --file /tmp/acme-$(hostname).json --users skip

The admin console’s partial export also works, as long as both sides use the same choices for groups, roles and clients. Do not mix a partial export with a full one: the masked secrets and missing users would show up as differences that are not real.

Where it helps

Staging and production drift

Export the same realm from both environments and compare. Expected differences, such as redirect URIs with other host names, are easy to spot and skip. Unexpected ones, such as a flow edited only in production, are the reason to look.

Reviewing a change

Export before and after a change in the admin console. The diff shows exactly what the change touched, which is often more than the person who made it remembers. Keep the report with the change record.

Checking an import or a migration

After you import a realm into a new server or a new Keycloak version, export it again and compare with the file you imported. Differences show what the import changed or dropped. Some differences are normal across versions, because newer releases add settings or defaults. Read those as information, not errors. If you are moving to managed hosting, the same check fits the dry run described on our migration page.

Configuration in version control

Teams that keep sanitized exports in a repository can compare any two commits here when a line-based diff is too noisy, and attach the report to the pull request.

Reading the results

  • Added means the object or field exists in B only. For clients and roles, that is something new in the later export.
  • Removed means it exists in A only. Check whether the removal was intended before you copy configuration between environments.
  • Changed shows the old value, an arrow, and the new value. For lists of values, it shows the items taken out with a minus and the items added with a plus.

A change in a secret field shows up as a change only if both files hold the value. If one export is masked or sanitized and the other is not, secrets appear as changed. Compare files cleaned the same way.

Common causes of noise

DifferenceUsual causeWhat to do
Every client changedIds compared across serversTurn on Ignore internal ids.
Many new settingsExports from different Keycloak versionsExpect it; review only the settings you use.
Secrets changedOne file masked, one notSanitize both the same way.
Users added or removedOne export has users, the other does notExport both with the same --users option.
Host names in URIsEnvironment-specific redirect URIsExpected; check the rest of the client.

Security notes

Exports can hold secrets and personal data. Both files are read in your browser and nothing leaves the page, but the text report repeats the old and new values of what changed. If a secret or a user’s detail changed, it appears in the report. Run the files through the realm export sanitizer first when the report will be shared.

Best practices

  • Export both sides the same way: same command, same --users option, same sanitizing.
  • Compare one realm at a time.
  • Keep a known-good export of each production realm and compare against it after every change window.
  • Make configuration changes in staging first, then use the diff to confirm production received exactly the same change.
  • When a difference is expected forever, such as host names, note it in the review so the next person does not chase it.
Questions

Frequently asked questions

How do I compare two Keycloak realms?

Export each realm to JSON and compare the files with a tool that matches objects by name instead of by line. This one matches clients by client id, roles by name, groups by path and flows by alias.

Why does a diff of two Keycloak exports show every client as changed?

Each server gives objects its own internal ids, so the same client has a different id on staging and production. Ignore ids when you compare exports from different servers.

Can I see what changed in a Keycloak realm over time?

Keep exports from different dates and compare them. If admin events with representations are saved, they also record changes as they happen.

Does the order of redirect URIs or roles matter?

No. The tool treats lists of plain values as sets, so a different order is not reported as a change. Items added or removed are listed.

Can this tool apply the differences to a realm?

No. It only reports them. To apply a change, make it in the admin console, through the admin API, or with a partial import, and compare again afterwards.

Why do exports from different Keycloak versions differ?

Newer versions add realm and client settings, and an import into a newer version can fill in their defaults. Expect such differences after an upgrade and focus on the settings you rely on.

Should I include users when comparing realms?

Usually not. Configuration reviews rarely need them, and users add noise and personal data to the report. Export with `--users skip` on both sides unless user data is what you want to compare.

Are my realm exports uploaded?

No. Both files are read and compared in your browser. The report can contain changed values, so treat it like the exports themselves.

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.