Skip to content

Keycloak realm export sanitizer

Remove client secrets, identity provider secrets, private keys, LDAP passwords and user credentials from a Keycloak realm export before you share it, with a list of everything that was taken out.

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

Realm export

A made-up sample realm with fake secrets is filled in. Paste your export or open the file; it stays in your browser.

Secrets

Sanitized export

Masked or removed 8 items
Review the file before you share it. This tool knows Keycloak’s secret fields and catches names that look like secrets, but it cannot see a secret stored under another name, for example in a custom attribute, a mapper’s config or a theme property.
1 user, with their personal data and credentials
users
SMTP password
smtpServer.password
client secret
clients[billing-service].secret
client secret
clients[legacy-portal].secret
identity provider client secret
identityProviders[google].config.clientSecret
realm private key
components.org.keycloak.keys.KeyProvider[rsa-generated].config.privateKey
key material (HMAC or AES secret)
components.org.keycloak.keys.KeyProvider[hmac-generated].config.secret
LDAP bind password
components.org.keycloak.storage.UserStorageProvider[corporate-ldap].config.bindCredential
Sanitized JSON
{
  "realm": "acme",
  "enabled": true,
  "sslRequired": "external",
  "registrationAllowed": true,
  "bruteForceProtected": false,
  "passwordPolicy": "length(8)",
  "accessTokenLifespan": 300,
  "ssoSessionIdleTimeout": 1800,
  "ssoSessionMaxLifespan": 36000,
  "loginTheme": "acme-theme",
  "eventsEnabled": false,
  "adminEventsEnabled": false,
  "smtpServer": {
    "host": "smtp.example.com",
    "port": "587",
    "from": "[email protected]",
    "auth": "true",
    "user": "mailer",
    "password": "**********"
  },
  "roles": {
    "realm": [
      {
        "name": "user",
        "description": "Signed-in user"
      },
      {
        "name": "admin",
        "description": "Acme administrators"
      },
      {
        "name": "offline_access"
      },
      {
        "name": "uma_authorization"
      },
      {
        "name": "default-roles-acme",
        "composite": true
      }
    ],
    "client": {
      "web-app": [
        {
          "name": "editor"
        },
        {
          "name": "viewer"
        }
      ],
      "realm-management": [
        {
          "name": "view-users"
        },
        {
          "name": "manage-users"
        }
      ]
    }
  },
  "groups": [
    {
      "name": "staff",
      "path": "/staff",
      "subGroups": [
        {
          "name": "support",
          "path": "/staff/support"
        }
      ]
    }
  ],
  "clients": [
    {
      "clientId": "web-app",
      "enabled": true,
      "publicClient": true,
      "standardFlowEnabled": true,
      "implicitFlowEnabled": true,
      "directAccessGrantsEnabled": true,
      "redirectUris": [
        "https://app.example.com/*"
      ],
      "webOrigins": [
        "+"
      ],
      "attributes": {}
    },
    {
      "clientId": "billing-service",
      "enabled": true,
      "publicClient": false,
      "clientAuthenticatorType": "client-secret",
      "secret": "**********",
      "standardFlowEnabled": false,
      "serviceAccountsEnabled": true,
      "redirectUris": [],
      "webOrigins": [],
      "attributes": {}
    },
    {
      "clientId": "legacy-portal",
      "enabled": true,
      "publicClient": false,
      "secret": "**********",
      "standardFlowEnabled": true,
      "redirectUris": [
        "*"
      ],
      "webOrigins": [
        "*"
      ],
      "attributes": {}
    },
    {
      "clientId": "account",
      "enabled": true,
      "publicClient": true
    },
    {
      "clientId": "admin-cli",
      "enabled": true,
      "publicClient": true
    }
  ],
  "identityProviders": [
    {
      "alias": "google",
      "providerId": "google",
      "enabled": true,
      "config": {
        "clientId": "sample-google-client-id",
        "clientSecret": "**********"
      }
    }
  ],
  "components": {
    "org.keycloak.keys.KeyProvider": [
      {
        "name": "rsa-generated",
        "providerId": "rsa-generated",
        "config": {
          "priority": [
            "100"
          ],
          "privateKey": [
            "**********"
          ],
          "certificate": [
            "MIICsample-certificate"
          ]
        }
      },
      {
        "name": "hmac-generated",
        "providerId": "hmac-generated",
        "config": {
          "secret": [
            "**********"
          ]
        }
      }
    ],
    "org.keycloak.storage.UserStorageProvider": [
      {
        "name": "corporate-ldap",
        "providerId": "ldap",
        "config": {
          "connectionUrl": [
            "ldaps://ldap.example.com"
          ],
          "bindDn": [
            "cn=reader,dc=example,dc=com"
          ],
          "bindCredential": [
            "**********"
          ]
        }
      }
    ]
  },
  "authenticationFlows": [
    {
      "alias": "browser",
      "topLevel": true,
      "builtIn": true,
      "authenticationExecutions": []
    },
    {
      "alias": "browser-with-sms",
      "topLevel": true,
      "builtIn": false,
      "authenticationExecutions": [
        {
          "authenticator": "auth-cookie",
          "requirement": "ALTERNATIVE"
        },
        {
          "authenticator": "auth-username-password-form",
          "requirement": "REQUIRED"
        },
        {
          "authenticator": "acme-sms-otp",
          "requirement": "REQUIRED"
        }
      ]
    }
  ]
}
Keycloak cannot restore secrets from a masked file. If you import it, set the real secrets again afterwards.

How to use it

  1. Paste the realm export or open the file. It stays in your browser.
  2. Choose whether to mask secrets with ********** or remove the fields.
  3. Decide whether to drop users and their personal data.
  4. Read the list of what was removed, then review the file yourself.
  5. Copy the result or save it as a new file.

What to know

A full realm export carries the secrets that keep a realm safe: client secrets, the private keys realms sign tokens with, identity provider secrets, the LDAP bind password and SMTP password, and every user’s password hash and OTP secret.

The sanitizer removes Keycloak’s known secret fields and, if you leave the option on, any other field whose name looks like a secret or a password. It lists each one by path, so you can see exactly what changed.

It cannot find a secret stored under a name it does not expect, for example in a custom attribute, a mapper’s config or a script. Always read the file before you send it to anyone.

Why realm exports need cleaning

A realm export is the easiest way to show someone how a Keycloak realm is set up. Support engineers ask for it, consultants review it, and teams keep it next to their code. The trouble is that a full export from kc.sh export holds more than configuration. It holds the secrets that protect the realm.

Anyone with those secrets can act as your applications, sign tokens your apps will trust, or read the password hashes of every user. A file like that should never reach a ticket, a chat thread or a public repository as it is.

What secrets a Keycloak export contains

WhereFieldWhat it unlocks
Confidential clientssecretGetting tokens as that client, for example with the client credentials grant.
Identity providersconfig.clientSecretActing as your realm toward Google, Microsoft or another provider.
Key providersprivateKey, secretSigning tokens, or HMAC and AES keys, that your apps trust.
LDAP federationbindCredentialReading, and maybe writing, your directory.
SMTP settingssmtpServer.passwordSending mail as your realm.
UserscredentialsPassword hashes and OTP secrets, open to offline guessing.

Users also carry personal data: usernames, email addresses, names and attributes. Even without credentials, that data is often covered by privacy rules.

What this tool does

The sanitizer walks the whole JSON tree of the export in your browser and treats secrets in three ways.

Known secret fields

Fields Keycloak uses for secrets are handled wherever they appear: secret, clientSecret, password, bindCredential, privateKey, keystorePassword, keyPassword, registrationAccessToken and secretData. Each one is named in the report with its path, such as clients[billing-service].secret.

Fields that look like secrets

With the extra option on, any other field whose name contains secret, password or private key, and which holds a real value, is masked too. Names that only describe a setting, such as passwordPolicy or a URL, are left alone. Values written as ${...} placeholders are kept, since they point to a vault or environment variable rather than holding the secret.

Users

By default the whole users list is removed, with its personal data. If you keep users, their credentials are still removed, so no password hash or OTP secret stays in the file.

Mask or remove

You choose what happens to each secret.

  • Mask replaces the value with **********, the same text Keycloak’s own partial export uses. The structure stays, so a reviewer can see that a client has a secret without seeing it.
  • Remove deletes the field. The file is smaller and cannot be mistaken for a working export.

Neither choice can be undone from the file. If you import a sanitized export, Keycloak gets a masked value or no value at all, so you set those secrets again afterwards: new client secrets, the identity provider secrets, the LDAP bind password and the SMTP password. Key providers without their private keys need new keys, and tokens signed with the old keys stop verifying.

What it cannot find

The tool knows Keycloak’s field names. It cannot know your own. A secret stored under another name passes through untouched, for example:

  • a token kept in a custom user or client attribute;
  • an API key in the config of a protocol mapper or a custom provider;
  • a webhook URL with a key in its query string;
  • a value in a theme property or a script.

That is why the report always ends with a reminder to read the file yourself before you send it. Search it for words such as key, token, secret and password, and look at any long random-looking strings.

How to use it

  1. Export the realm with kc.sh export or the admin console.
  2. Open the file with Open a file, or paste it. A made-up sample realm with fake secrets is filled in to show how it works.
  3. Choose mask or remove, and whether to drop users.
  4. Read the list of what was taken out. Each line has the reason and the path.
  5. Search the result for anything the tool could not know about.
  6. Copy the JSON or save it with Save file, under a new name.
Example: what the report lists for the sample realm
client secret                     clients[billing-service].secret
identity provider client secret   identityProviders[google].config.clientSecret
realm private key                 components.org.keycloak.keys.KeyProvider[rsa-generated].config.privateKey
LDAP bind password                components.org.keycloak.storage.UserStorageProvider[corporate-ldap].config.bindCredential

When to use it

Asking for help

A support engineer or a community forum can often spot a problem from the realm configuration alone. Send a sanitized export without users; it shows the settings and flows without handing over access.

Keeping configuration in Git

Teams that track realm changes in a repository should commit sanitized exports only. Pair it with the realm export diff to review what changed between commits.

Moving to another environment or provider

When a realm moves from one setup to another, the people planning the move need its configuration long before they need its secrets. Share a sanitized copy for planning, and move the secrets separately, through a channel meant for secrets. For a move to managed hosting, see how migration works.

Audit and review

Reviewers need to see that secrets exist and where, not their values. Masking keeps that information in place.

If an export has already leaked

Treat every secret in it as known to others and rotate them. In practice that means:

  1. Regenerate the secret of each confidential client and update the apps that use it.
  2. Add new keys under Realm settings, Keys, make them active, and retire the old ones once tokens signed with them have expired.
  3. Create new client secrets at each identity provider and update them in Keycloak.
  4. Change the LDAP bind password and the SMTP password.
  5. If users and credentials were in the file, consider requiring a password change for them.

Common mistakes

  • Sharing the users file. With kc.sh export --dir, users sit in their own files next to the realm file. Clean those too, or leave them out.
  • Trusting the mask alone. A partial export hides secrets, but it can still name internal hosts, LDAP base DNs and admin usernames you may not want to share.
  • Cleaning a copy and sending the original. Save the result under a new name, such as acme-sanitized.json, and attach that file.
  • Forgetting old copies. Exports left in downloads folders, build logs or old tickets keep their secrets. Search for them and delete them.
  • Importing a masked file into production. Keycloak cannot recover masked secrets, so apps that use those clients stop working until you set real secrets.

Privacy of this page

The file is read with the browser’s FileReader. Parsing, cleaning and saving all happen on your computer; Save file writes a new file without any upload. Nothing you paste is sent to us. Close the tab when you are done, so the original stays only where you keep it.

Best practices

  • Prefer the admin console’s partial export when users are not needed. It masks secrets already, and the sanitizer then catches the rest.
  • Store secrets in a vault and reference them with ${vault.name} style placeholders, so exports do not hold them at all.
  • Never commit an unsanitized export, even to a private repository.
  • Sanitize before you analyze or compare, if other people will see the results.
  • Keep the original export encrypted, or delete it once you no longer need it.
Questions

Frequently asked questions

Does a Keycloak realm export contain secrets?

A full export from `kc.sh export` does: client secrets, the realm’s private keys, identity provider secrets, the LDAP bind password, the SMTP password and users’ credentials. The admin console’s partial export masks secrets but can still contain other sensitive settings.

How do I remove client secrets from a Keycloak export?

Run the file through this sanitizer, which masks or removes each `secret` and the other known secret fields and lists them. Then read the file yourself for secrets under other names.

Can I import a sanitized realm export?

Yes, but the secrets are gone. Set new client secrets, add the identity provider, LDAP and SMTP secrets again, and plan for new realm keys if the key providers were cleaned.

What does ********** mean in a Keycloak export?

It is the mask Keycloak’s partial export writes in place of a secret. Importing it does not restore the real value.

Is it safe to upload a realm export here?

Nothing is uploaded. The page reads the file in your browser and writes the cleaned copy back to your computer.

Why should I remove users from an export?

Users carry personal data and, in a full export, their password hashes and OTP secrets. Few reviews need them, so leaving them out lowers the risk of sharing the file.

Can the sanitizer miss a secret?

Yes. It knows Keycloak’s secret fields and names that look like secrets, but not secrets stored under other names, such as in custom attributes or mapper settings. Always review the result.

What should I do if an unsanitized export was shared?

Rotate everything in it: client secrets, realm keys, identity provider secrets, the LDAP bind password and the SMTP password. If credentials were included, consider asking users to change their passwords.

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.