Comments are sentences in Hocon configuration that allow users to read and understand the configuration better. Comments help to understand the configuration better and provide context to updates or add extra configuration.

Let’s see How to write comments in multiple ways.

  • Single Line Comments

    • Single Line comments always start with # or double slashes //,
    • All the text followed by # or // are comments, and ignored.
    • These comments are in new lines or inline
# Single-line comment
database = "mysql" # Inline comment
  • Multi-Line Comments

There are no multi-line comments supported, But you can prefix # or // on a new line. Commented lines do spans in multiple lines.

# Multi-line comment example
# Another multiple line
database = "mysql"

  • Inline Comments

Inline comments are placed at the end of a line. There is a space between value and comment syntax.

database = "mysql" # Inline comment
  • Block Comments:

There is no support for block comments syntax.

Comments are helpful for users to improve readability, but programs or parsers ignore the comment's text. 

The below example shows all single, multi, and inline comment examples

# Single line comment
// Another way to write a Single line comment

database = "mysql" # Inline comment

# This is a multi-line comment
# that spans multiple lines
appname = "myapp"

# Comment actual key and pairs
# hostname = "localhost"


ssl = "true" # Inline comment