Comments are simple text statements to explain about configuration code. It Helps developers and users understand modify and update the configuration easily. Applications or programs that parse configuration ignore the comments.

Like any other file extensions, Comments are allowed in Init files.

The following comments are supported

  • Single Line comments
  • Inline Comments
  • Block comments are not supported, Can write multi-line comments with single line syntax.

How to write Comments in an INI file?

There are two ways to write a single or inline comment.

Single line comments using semicolon

One is using the Semicolon symbol ; placed at the beginning of each line followed by comment text.

Important rules

  • Comments must prefix semicolon followed by a space
  • Comments must be single line only and closed
  • Inline comments added to the end of configuration by including space followed by comments

Here is a syntax

; database configuration

[database]
hostname = "localhost:3201"
; database username
user = "admin"

password = "admin"; database password, not recommended and secure.

Single line comments using Hash

Another way to use the hash symbol # for key and value pair comments. hashing syntax only supports some of the implementations and space after the # symbol is recommended.

You can also comment on key and value pairs, ignored by parsers.

# database configuration

[database]
hostname = "localhost:3201"
# database username
user = "admin"

password = "admin" # database password, not recommended and secure.
#enable_debug =  true

Ini Multi line Comments

multi-line or block comments are not supported by default. However, can add multiple lines of comments by prefixing ; or #, followed by comments text.

; this is the beginning of the ini file and multi-line example
; empty lines are ignored
; Inline comments example

[settings]
enable_ssl = true
enable_2mf =  true


These files do not support multi-line

Ini file comments example

It is included in package.json as follows.

; this is the beginning of the ini file
; empty lines are ignored
; Inline comments example
key1=value1
# keycomment=example

Ini Comments notes:

  • Inline comments are allowed
  • Block comments are not supported
  • Comments format represented in two formats
  • Comments text are not processed or interpreted by programming languages.
  • Add simple and clean language for the comment string.
  • Don’t store secure information such as secret keys and tokens
  • Use one of the ; or # syntax for comments to have a clean and readable code
  • Avoid usage of duplicate and excessive comments
  • Also add review comments whenever there is a change to the ini file, improves maintainability