To comment in the .env file, use the “hash(#) symbol”. The interpreter interprets anything written after the hash # symbol as a comment in .env files.
For example, laravel’s env file looks like this:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=true
We can add comments on separate lines by starting the line with a “hash # symbol.”
# Application name and environment
APP_NAME=Laravel
APP_ENV=local
# Application key and debugging
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=true
Adding a comment at the end of a line
You can add the comments at the end of the line in the .env file, which is perfectly valid and won’t cause any errors.
APP_NAME=Laravel # Application name
APP_ENV=local # Environment
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Application key
APP_DEBUG=true # Debugging
Multiline comments are not available in the .env file
We have no character sequence that can be used to create multiline comments in the .env file.
To comment out multiple lines, start each line with a hash # symbol.
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=true
# Application name
# Environment
# Application key and debugging
This approach is fine but not user-friendly.
Based on my experience, the first approach is to add comments on separate lines by starting the line with a “hash # symbol” correctly.

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.