.properties
.properties files are a file extension predominantly associated with Java ecosystems, used to store configurable settings for applications. They also play a role in Internationalization and localization by functioning as Property Resource Bundles for managing string resources.
Each entry consists of a key paired with a corresponding value, both represented as strings.
Due to their straightforward nature, .properties files do not have an official RFC specification.
Format
Typically, each line defines a single property using formats such as key=value, key:value, or key value. Quotation marks are interpreted literally as part of the string. Lines beginning with a number sign (#) or exclamation mark (!) are considered comments and ignored. The backslash character is used for escaping special characters or for indicating that the line continues onto the next.
An example set of properties:
<syntaxhighlight lang="properties" line="1">
- Lines starting with # or ! are comments
website = https://en.wikipedia.org/ language : English topic .properties files empty hello=hello whitespaceStart = \ duplicateKey = second delimiterCharacters\:\=\ = Value with delimiters multiline = This line \ continues path = c:\\wiki\\templates evenKey = This is on one line\\ oddKey = This is line one and\\\ welcome = Welcome to \
Wikipedia!
valueWithEscapes = Newline\n Carriage return\r Tab\t encodedHelloInJapanese = \u3053\u3093\u306b\u3061\u306f helloInJapanese = こんにちは </syntaxhighlight>
Prior to Java 9, .properties files were encoded using ISO-8859-1, requiring non-ASCII characters to be represented through Unicode escape sequences (e.g., \uHHHH). This approach facilitated their use in localization resource bundles. Utilities such as native2ascii or po2prop convert files into this encoding.
Starting with Java 1.5, an XML-based Properties format supporting UTF-8 encoding was introduced as an alternative. Additionally, custom encoding options can be configured.
From Java 9 onwards, UTF-8 became the default encoding for property resource bundles, with ISO-8859-1 serving as a fallback for invalid byte sequences.
Editing
Editing .properties files can be accomplished using any standard text editor available across different operating systems, including tools like Notepad on Windows or editors such as Emacs and Vim on Linux.
There are also specialized third-party applications designed to enhance management of .properties files by providing features such as:
- Validation of data
- Adding new keys efficiently
- Synchronizing key names across files
- Automatic two-way conversion of non-ASCII characters to support non-Latin alphabets
- Seamless integration with development environments like Eclipse
Non-Java uses and exceptions
Apache Flex employs .properties files encoded in UTF-8 format.
Within Apache mod_jk, the uriworkermap.properties file interprets an initial exclamation mark ("!") on a line as a Negation operator.
The Perl community provides Config::Properties via CPAN for handling .properties files.
SAP uses .properties files to manage localization within its SAPUI5 framework and its open-source counterpart, OpenUI5.
A wide range of packages available on Npm for Node.js, along with numerous PHP libraries, offer support for working with .properties files.