PlaceholdersKeePass supports various placeholders. |
In many places in KeePass (auto-type, URL field, triggers, ...), placeholders can be used.
KeePass uses the abbreviation "Spr" for "String placeholder replacement". An Spr-compiled field is a field where placeholders are replaced when performing an action with this field (like copying it to the clipboard, sending it using auto-type, etc.).
References in a field to (parts of) the field itself are
unsupported. For example, the {URL:HOST}
placeholder
cannot be used in the URL field (but it can be used in the
'Override URL' field).
Placeholder | Field |
---|---|
{TITLE} | Title |
{USERNAME} | User name |
{URL} | URL |
{PASSWORD} | Password |
{NOTES} | Notes |
{S:Name}
.
For example, if you have a custom string named "eMail",
you can use the placeholder {S:eMail}
.
Placeholder | Is Replaced By |
---|---|
{URL:RMVSCM} | Entry URL without scheme name. |
{URL:SCM} | Scheme name of the entry URL. |
{URL:HOST} | Host component of the entry URL. |
{URL:PORT} | Port number of the entry URL. |
{URL:PATH} | Path component of the entry URL. |
{URL:QUERY} | Query information of the entry URL. |
{URL:USERINFO} | User information of the entry URL. |
{URL:USERNAME} | User name of the entry URL. |
{URL:PASSWORD} | Password of the entry URL. |
{UUID} | UUID of the entry (32 hexadecimal characters). |
{URL:...}
placeholders can be found below.
Fields of other entries can be inserted using Field References.
Placeholder | Is Replaced By |
---|---|
{EDGE} | Path to Microsoft Edge, if installed. |
{FIREFOX} | Path to Mozilla Firefox, if installed. |
{GOOGLECHROME} | Path to Google Chrome (or Chromium on Unix-like systems), if installed. |
{INTERNETEXPLORER} | Path to Internet Explorer, if installed. |
{OPERA} | Path to Opera, if installed. |
{SAFARI} | Path to Safari, if installed. |
Placeholder | Is Replaced By |
---|---|
{APPDIR} | KeePass application directory path. |
Placeholder | Is Replaced By |
---|---|
{GROUP} | Name of the entry's parent group. |
{GROUP_PATH} | Full path of the entry's parent group. |
{GROUP_NOTES} | Notes of the entry's parent group. |
{GROUP_SEL} | Name of the group that is currently selected in the main window. |
{GROUP_SEL_PATH} | Full path of the group that is currently selected in the main window. |
{GROUP_SEL_NOTES} | Notes of the group that is currently selected in the main window. |
{DB_PATH} | Full path of the current database. |
{DB_DIR} | Directory of the current database. |
{DB_NAME} | File name (including extension) of the current database. |
{DB_BASENAME} | File name (excluding extension) of the current database. |
{DB_EXT} | File name extension of the current database. |
{ENV_DIRSEP} | Directory separator ('\' on Windows, '/' on Unix). |
{ENV_PROGRAMFILES_X86} | This is
%ProgramFiles(x86)% , if it exists, otherwise %ProgramFiles% . |
Placeholder | Is Replaced By |
---|---|
{DT_SIMPLE} | Current local date/time as a simple, sortable string. For example, for 2012-07-25 17:05:34 the value is 20120725170534. |
{DT_YEAR} | Year component of the current local date/time. |
{DT_MONTH} | Month component of the current local date/time. |
{DT_DAY} | Day component of the current local date/time. |
{DT_HOUR} | Hour component of the current local date/time. |
{DT_MINUTE} | Minute component of the current local date/time. |
{DT_SECOND} | Second component of the current local date/time. |
{DT_UTC_SIMPLE} | Current UTC date/time as a simple, sortable string. |
{DT_UTC_YEAR} | Year component of the current UTC date/time. |
{DT_UTC_MONTH} | Month component of the current UTC date/time. |
{DT_UTC_DAY} | Day component of the current UTC date/time. |
{DT_UTC_HOUR} | Hour component of the current UTC date/time. |
{DT_UTC_MINUTE} | Minute component of the current UTC date/time. |
{DT_UTC_SECOND} | Second component of the current UTC date/time. |
System environment variables are supported.
The name of the variable must be enclosed in '%
' characters.
For example %TEMP%
is replaced by the user's temporary path.
Placeholder | Action |
---|---|
{T-REPLACE-RX:/Text/Search/Replace/} |
Searches the regular expression Search in Text and replaces all matches by Replace. See below. |
{T-CONV:/Text/Type/} |
Convert Text to Type. See below. |
{T-REPLACE-RX:/Text/Search/Replace/}
– Replace
Using Regular Expression::
' specifies the
separator character. Any character except '}
' can be used as separator
character.
It must not appear within the parameters.
For example,
{T-REPLACE-RX:/A/B/C/}
and
{T-REPLACE-RX:!A!B!C!}
are equivalent.
The last separator character (before the '}
') is required.myname@example.com
' and
the URL field '{T-REPLACE-RX:!{USERNAME}!.*@(.*)!https://$1!}
'.
When running the URL field, KeePass opens
'https://example.com
'.
{T-CONV:/Text/Type/}
– Convert:Bob
' and
the URL 'https://example.com/?user={T-CONV:/{USERNAME}/L/}
'.
When running the URL, KeePass opens
'https://example.com/?user=bob
'.+
'.
The auto-type sequence '{USERNAME}a
' results in the text
'+a
', whereas the auto-type sequence
'{T-CONV:/{USERNAME}/Raw/}a
' results in the text
'A
'
(because this placeholder inserts '+
' into the auto-type
sequence without encoding it, and
'+a
' means to press Shift+A,
which results in the text 'A
').Placeholder | Action |
---|---|
{PICKCHARS} {PICKCHARS:Fld:Opt} | Shows a dialog to pick certain characters from an entry string. See below. |
{PICKFIELD} | Shows a dialog to pick a field whose value will be inserted. |
{NEWPASSWORD} {NEWPASSWORD:/Profile/.../} | Generates a new password. See below. |
{PASSWORD_ENC} | Password in encrypted form. See below. |
{HMACOTP} | Generates an HMAC-based one-time password. See below. |
{TIMEOTP} | Generates a time-based one-time password. See below. |
{C:Comment} | Comment; is removed. |
{BASE} {BASE:RMVSCM} {BASE:SCM} {BASE:HOST} {BASE:PORT} {BASE:PATH} {BASE:QUERY} {BASE:USERINFO} {BASE:USERNAME} {BASE:PASSWORD} | Within a URL override, each of these placeholders is replaced by the specified part of the string that is being overridden. See below. |
{CLIPBOARD} |
Gets the clipboard content (text). |
{CLIPBOARD-SET:/Text/} |
Copies Text into the clipboard. |
{CMD:/CommandLine/Options/} |
Runs a command line. See below. |
{PICKCHARS}
– Picking Characters:{PICKCHARS}
placeholder shows a dialog, in which you can
pick characters of an entry string (like the password) at certain positions.{PICKCHARS}
without any parameters lets you pick an arbitrary
amount of characters from the password of the entry.
A different entry string can be specified by appending a ':
'
and the name of the field; e.g. {PICKCHARS:UserName}
.
The names of the standard fields are Title, UserName (without a space),
Password, URL and Notes. A custom entry string can
be referenced by its name (without an S:
prefix).:
'. If you want to specify
multiple options, separate them by a comma ',
'. Options are
key-value pairs, separated by a '=
'. The following options
are supported:
Conv=D, Conv-Offset=1
,
then '2', 'c' and 'C' are converted to 3 down arrow keypresses.Conv=D, Conv-Fmt=0A
.
Similarly, if it contains values A-Z0-9, specify Conv=D, Conv-Fmt=A0
.
If digits start with 1 instead of 0 (i.e. the 0 appears after the 9), use
1A
and A1
instead of 0A
and A0
.
If the combobox contains values 0-9A-Za-z (i.e. case-sensitive characters),
specify 0Aa
. All combinations of '0
', 'A
',
'a
' and '?
' are supported.
If 'A
' and 'a
' are not specified both,
characters are treated as case-insensitive.
'?
' skips a combobox item.{USERNAME}{TAB}{PICKCHARS:Password:C=5}{ENTER}
{S:Memorable}{TAB}{PICKCHARS:Password:ID=1, C=1, Conv=D,
Conv-Offset=1}{TAB}{PICKCHARS:Password:ID=2, C=1, Conv=D,
Conv-Offset=1}{TAB}{PICKCHARS:Password:ID=3, C=1, Conv=D,
Conv-Offset=1}{ENTER}
{S:Memorable}{TAB}{PICKCHARS:Password:C=3, Conv=D, Conv-Offset=1}
,
all the down arrow keypresses are sent to the same, currently active control.{DELAY 250}
after each {TAB}
,
or slowing down the whole sequence, e.g. by prepending {DELAY=150}
.
{NEWPASSWORD}
and {NEWPASSWORD:/Profile/.../}
– Generating New Passwords:{NEWPASSWORD}
placeholder generates a new password
for the current entry, based on the
'Automatically generated passwords for new entries'
generator profile.{PASSWORD}{TAB}{NEWPASSWORD}{TAB}{NEWPASSWORD}{ENTER}
as auto-type sequence.{NEWPASSWORD:/Profile/}
, where Profile
is the name of the profile.
If the specified profile cannot be found, the
'Automatically generated passwords for new entries' profile is used.~
:
When specifying '~
' as name of the profile
(i.e. when using the placeholder {NEWPASSWORD:/~/}
), KeePass
derives
a profile from the current entry password.
Not recommended, as the quality can degrade.#
:
When specifying '#
' as name of the profile,
you can specify two additional parameters: a
pattern and an option.
R
:
Specifies whether to rearrange/permute the characters of the generated
password randomly.0
.
0
:
Do not rearrange.1
:
Rearrange.{NEWPASSWORD:/#/H\2\-HH\-HH\-HH\-HH\-HH/}
{NEWPASSWORD:/#/uldA{17}/R=1/}
{NEWPASSWORD}
placeholder,
{NEWPASSWORD:/.../}
placeholders are evaluated only once
(even when different profiles/parameters are specified).
{PASSWORD_ENC}
– Encrypting Passwords:{PASSWORD_ENC}
placeholder is replaced by the password
of the current entry in encrypted form. The password is encrypted using
credentials of the current Windows user. The encrypted password should
not be stored and only works for the current user.-pw-enc
command line parameter
(see the URL Field page for
an example how to define a URL to open an additional KeePass database).
The placeholder cannot be used to transfer passwords to other applications
(except KeePass), because the target applications don't know how to decrypt
encrypted passwords generated by {PASSWORD_ENC}
.
{HMACOTP}
and
{TIMEOTP}
placeholders.
The parameters for the OTP generation are stored as entry strings and can be edited conveniently using the 'OTP Generator Settings' dialog (which checks the entered values, shows a preview, etc.). Alternatively, you can edit the entry strings directly, as documented below.
{HMACOTP}
– Generating HMAC-Based One-Time Passwords:
The {HMACOTP}
placeholder generates an HMAC-based one-time
password (HOTP) according to RFC 4226.
The shared secret and other parameters can be specified using the following entry string fields (which can be added/edited in the entry dialog on the 'Advanced' tab page):
{HMACOTP}
placeholder is replaced (i.e. when generating
a one-time password), KeePass updates the counter value automatically.{TIMEOTP}
– Generating Time-Based One-Time Passwords:
The {TIMEOTP}
placeholder generates a time-based one-time
password (TOTP) according to RFC 6238.
The shared secret and other parameters can be specified using the following entry string fields (which can be added/edited in the entry dialog on the 'Advanced' tab page):
The date and the time of your system must be correct, otherwise the service/server may reject the generated OTP.
Usage example.
Create a new entry and change its default auto-type sequence to
{USERNAME}{TAB}{PASSWORD}{ENTER}{DELAY 3000}{HMACOTP}{ENTER}
.
Open the 'OTP Generator Settings' dialog, set the shared secret
for HMAC-based OTPs to '12345678901234567890' and select the UTF-8 encoding.
When performing auto-type, KeePass sends the user name, presses
Tab, sends the password, presses Enter,
waits 3 seconds, generates and sends a HMAC-based OTP and finally presses
Enter again.
The counter value for the OTP generation is updated automatically.
With the shared secret above and initial counter value 0, the following
OTPs are generated: 755224, 287082, 359152, 969429, 338314, ...
(more generated OTPs can be found in the example in RFC 4226).
{URL:...}
and {BASE:...}
:{URL:...}
placeholder is replaced by the specified part
of the current entry's URL; this typically is useful in an
entry-specific URL override (defined on the 'Properties' tab of the entry dialog).
The {BASE:...}
placeholder is replaced by the specified part
of the URL being overridden; this typically is useful in a
global URL override (defined in 'Tools' → 'Options' → tab 'Integration' →
button 'URL Overrides'), because there no entry context may be available.https://user:pw@keepass.info:80/path/example.php?q=e&s=t
,
the placeholders return the following values:Placeholder | Value |
---|---|
{URL} |
https://user:pw@keepass.info:80/path/example.php?q=e&s=t |
{URL:RMVSCM} |
user:pw@keepass.info:80/path/example.php?q=e&s=t |
{URL:SCM} |
https |
{URL:HOST} |
keepass.info |
{URL:PORT} |
80 |
{URL:PATH} |
/path/example.php |
{URL:QUERY} |
?q=e&s=t |
{URL:USERINFO} |
user:pw |
{URL:USERNAME} |
user |
{URL:PASSWORD} |
pw |
{BASE}
supports exactly the same parts as {URL}
.
{CMD:/CommandLine/Options/}
– Running a command line:{CMD:/CommandLine/Options/}
placeholder
runs the specified command line."
).:
' specifies the separator
character. It can be chosen freely (except '{
' and '}
'),
but it must not occur in the command line or any of the options.
For example, {CMD:/Notepad.exe/W=0/}
and
{CMD:!Notepad.exe!W=0!}
are equivalent.
The separator character at the end (before the '}
') is mandatory.=
'.
Multiple options must be separated using commas ',
'.M
:
Specifies the method for running/opening the executable/document.S
.
S
:
Use the system shell (via ShellExecute
).
With this, executable files are executed and documents are opened
using their associated applications.
However, no standard input/output is supported.C
:
Run an executable file (EXE or COM, via CreateProcess
);
documents are not supported.
Standard input/output is supported.O
:
Specifies what to do with the standard output of the executed application.1
.
0
:
Ignore the standard output. The placeholder is replaced by an empty string.1
:
Replace the placeholder by the standard output.W
:
Specifies whether to wait for the termination of the executed application.1
.
0
:
Do not wait.1
:
Wait.WS
:
Specifies the window style. Not all applications support this option.N
.
N
:
Normal.H
:
Hidden.Min
:
Minimized.Max
:
Maximized.V
:
Specifies the verb (action to be performed),
e.g. 'Open' or 'Print'.
When using the verb 'RunAs', the application is executed with administrative
rights (this may require a confirmation via the UAC dialog).New-line characters at the end of the output are removed (analogous to
'$(...)
' and '`...`
' shell command substitutions).
{CMD:/Notepad.exe/W=0/}
{CMD:/PowerShell.exe -Command "(Get-FileHash '%SYSTEMROOT%\Win.ini'
-Algorithm SHA256).Hash"/M=C,WS=H/}