Skip to content

Keycloak config converter

Convert Keycloak options between command-line flags, KC_ environment variables, Docker Compose, Kubernetes env lists and keycloak.conf, following Keycloak’s own naming rule.

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

Your options

Paste a kc.sh command, .env or Compose lines, a Kubernetes env list or keycloak.conf. Mixing them is fine.

read as command line 8 options

db
KC_DBbuild option
db-url-host
KC_DB_URL_HOST
db-url-database
KC_DB_URL_DATABASE
db-username
KC_DB_USERNAME
hostname
KC_HOSTNAME
http-enabled
KC_HTTP_ENABLED
proxy-headers
KC_PROXY_HEADERS
health-enabled
KC_HEALTH_ENABLEDbuild option

Converted

Configuration
KC_DB=postgres
KC_DB_URL_HOST=postgres
KC_DB_URL_DATABASE=keycloak
KC_DB_USERNAME=keycloak
KC_HOSTNAME=https://auth.example.com
KC_HTTP_ENABLED=true
KC_PROXY_HEADERS=xforwarded
KC_HEALTH_ENABLED=true
Build options
db, health-enabled are build options. A server started with --optimized needs kc.sh build again after a change; plain start rebuilds on its own.

How to use it

  1. Paste a kc.sh command, KC_ variables, a Compose or Kubernetes env block, or keycloak.conf lines.
  2. Check the list of options it read and their environment names.
  3. Pick the format you need and copy it.
  4. Read the notes on build options, secrets and names it does not know.

What to know

Every Keycloak option has three spellings. The option db-url-host is --db-url-host=… on the command line, db-url-host=… in conf/keycloak.conf and KC_DB_URL_HOST as an environment variable: KC_, the name in capitals, dashes turned into underscores.

When the same option is set in more than one place, the command line wins over environment variables, which win over keycloak.conf.

Some options are build options, such as db, features, health-enabled and metrics-enabled. A server started with --optimized needs kc.sh build again after one of them changes.

One option, several spellings

Keycloak’s Quarkus distribution reads its configuration from several places: the command line, environment variables, and the file conf/keycloak.conf. Every option exists in all three, under a predictable name. The option that sets the database host is db-url-host. On the command line it is --db-url-host=…, in keycloak.conf it is db-url-host=…, and as an environment variable it is KC_DB_URL_HOST.

The rule is simple, yet the spellings drift apart in real projects. A team starts with a kc.sh command in a README, moves to a Compose file with environment variables, and later to a Kubernetes env list. Each move is a chance to drop an option or mistype one. This converter reads options in any of those forms and writes them back in the one you need.

The mapping rule

To get the environment variable from an option name, put KC_ in front, write the name in capitals, and replace each dash with an underscore. To go back, drop KC_, use lower case, and turn underscores into dashes.

OptionCommand lineEnvironment variablekeycloak.conf
db--db=postgresKC_DB=postgresdb=postgres
db-url-host--db-url-host=postgresKC_DB_URL_HOST=postgresdb-url-host=postgres
hostname--hostname=https://auth.example.comKC_HOSTNAME=https://auth.example.comhostname=https://auth.example.com
proxy-headers--proxy-headers=xforwardedKC_PROXY_HEADERS=xforwardedproxy-headers=xforwarded
health-enabled--health-enabled=trueKC_HEALTH_ENABLED=truehealth-enabled=true

The addresses above are made-up samples.

Which source wins

When the same option is set in more than one place, the command line wins over environment variables, and environment variables win over keycloak.conf. That is useful: a container image can ship a keycloak.conf with sensible values, and each environment overrides what differs with variables.

SPI options

Options for individual providers start with spi-. Their names contain the provider’s ids, which can contain dashes themselves. In the environment form, a dash and a separator both become underscores, so the way back from a KC_SPI_… name can be ambiguous. Check a converted SPI option against the provider’s documentation.

Build options and runtime options

Keycloak separates options that shape its optimized build from options read at every start. Build options include db, features, health-enabled and metrics-enabled. Runtime options include the hostname, database URL and credentials.

With plain kc.sh start, Keycloak notices changed build options and rebuilds on its own, which makes the start slower. With kc.sh start --optimized, it skips that check, so you must run kc.sh build after changing a build option. Container images built for fast starts usually run kc.sh build in the Dockerfile and start --optimized at run time.

An optimized image
FROM quay.io/keycloak/keycloak:26.8.1 AS builder
ENV KC_DB=postgres
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
RUN /opt/keycloak/bin/kc.sh build

FROM quay.io/keycloak/keycloak:26.8.1
COPY --from=builder /opt/keycloak/ /opt/keycloak/
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
CMD ["start", "--optimized"]

The converter marks the build options it knows about, so you can see which changes need a rebuild.

Values that need care

The option name follows one rule, but values differ in how each format treats them. Most surprises come from three kinds of value.

Lists

Some options take a comma-separated list. features lists preview or optional features to turn on, and log-level takes a default level followed by per-category levels, such as info,org.keycloak:debug. Keep the list as one value. Do not split it across several variables or lines.

Booleans and numbers

Keycloak reads true and false as text. In YAML, an unquoted true or 8080 becomes a boolean or a number, and Kubernetes refuses a non-string env value. The converter writes every YAML value in single quotes so this cannot happen.

Characters the shell cares about

A value with spaces, $, & or quotes needs quoting on the command line and in .env files that a shell reads. The converter quotes such values for the shell. A database password full of symbols is the usual case.

What this tool does and does not do

  • It reads a kc.sh command line, including --name=value, --name value and continued lines ending in a backslash.
  • It reads KC_ variables from .env lines, export statements, Compose environment blocks in both map and list form, and Kubernetes name: and value: pairs.
  • It reads keycloak.conf lines and skips comments.
  • It writes the options as a command line, .env lines, a Compose environment block, a Kubernetes env list or keycloak.conf.
  • It flags names outside its list of common options, build options, secrets written in plain text and SPI options.
  • It keeps command flags such as --optimized and --import-realm in the command-line form only.
  • It does not know every option of every version, check values, or read a running server.

How to use it

  1. Paste what you have: a command, a Compose service’s environment, a Kubernetes env list or a keycloak.conf. Mixing them in one paste works.
  2. Check the table of options the tool read, with the environment name of each.
  3. Pick the output format you need and copy it.
  4. Read the notes. Fix any name the tool did not recognize, and move secrets out of files.

Where it pays off

From a VM to containers

A Keycloak that ran on a VM often keeps its settings in keycloak.conf or a systemd unit with a long command. Paste either, choose the Compose or Kubernetes form, and you have the environment block for the new deployment.

From Compose to Kubernetes

Compose and Kubernetes write environment variables differently. Paste the Compose block and copy the Kubernetes env list. For the Keycloak Operator, most options become fields of the resource and the rest go into additionalOptions under their plain names, which the converter also shows.

Reviewing someone else’s setup

When you inherit a deployment, settings are spread over a Dockerfile, a Compose file and a keycloak.conf. Paste them together to see the full list in one place, and spot an option set twice with different values.

After an upgrade from an older version

Several options were renamed or removed over Keycloak’s recent releases. The hostname options changed in Keycloak 25, for example, and the older proxy modes gave way to proxy-headers. The converter flags names outside its list, which is a quick way to find options to look up in the release notes.

Common errors and how to fix them

Keycloak refuses to start with an unknown option

On the command line Keycloak rejects an option it does not know. Check the spelling with kc.sh start --help, which lists the options of your version.

A setting seems to be ignored

In environment variables and keycloak.conf, a typo is easy to miss. Another source may also override the value, since the command line wins over the environment and the environment over the file. Paste every source together to see the final value.

A change has no effect after restart

If the server starts with --optimized and you changed a build option such as db or health-enabled, run kc.sh build again or rebuild the image.

Quotes end up in the value

Compose and Kubernetes YAML treat quotes as part of the syntax, but a .env file read by another tool may not. The converter quotes values where each format needs it. When you edit by hand, keep values such as true and port numbers quoted in YAML so they stay strings.

Security notes

  • Options such as db-password and bootstrap-admin-password hold secrets. Keep them in a secret store and inject them as environment variables.
  • A password on the command line shows up in process lists and shell history.
  • In keycloak.conf, ${VAR} reads a value from an environment variable, which keeps the secret out of the file.
  • Do not paste production secrets into any web page you do not trust. This page converts in your browser and sends nothing, but a placeholder works just as well.

Best practices

  • Pick one source of truth per environment, usually environment variables in containers.
  • Put build options into the image with kc.sh build, and keep runtime options outside it.
  • Keep option names in their plain form in documentation; the environment form follows from the rule.
  • Check the release notes for renamed options before an upgrade.

Moving realms to another server as well? The migration page describes how we move them into a managed cluster.

Questions

Frequently asked questions

How do I convert a Keycloak option to an environment variable?

Put `KC_` in front, write the name in capitals and replace dashes with underscores. `hostname-strict` becomes `KC_HOSTNAME_STRICT`, and `db-url-host` becomes `KC_DB_URL_HOST`.

Which takes precedence: keycloak.conf, environment variables or the command line?

The command line first, then environment variables, then `keycloak.conf`. A value set on the command line overrides the same option anywhere else.

Where is keycloak.conf in the container?

At `/opt/keycloak/conf/keycloak.conf` in the official image. Many container setups leave it as shipped and set everything through environment variables instead.

What is a build option in Keycloak?

An option baked into the optimized build, such as `db`, `features`, `health-enabled` or `metrics-enabled`. With `start --optimized` you must run `kc.sh build` after changing one. Plain `start` rebuilds on its own.

Can I use environment variables inside keycloak.conf?

Yes. A value such as `db-password=${DB_PASSWORD}` reads the environment variable `DB_PASSWORD` when Keycloak starts. It keeps secrets out of the file.

How do I list every option my Keycloak version supports?

Run `kc.sh start --help` or `kc.sh build --help` in the image. The output lists the options of that exact version.

Why is my KC_ environment variable ignored?

Check the spelling, since a typo in a variable name is easy to miss. Check that a command-line flag does not override it, and that a build option was rebuilt when you use `--optimized`.

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.