Comments
You shall comment ALL your code!
Comments are necessary for any programming language. BoxLang is no different in helping you add code comments in both script and tag syntax. The syntax is the same if you are a Java/Kotlin developer.
Tag Comments
You can use the <!--- and ---> Syntax to comment within a BoxLang template (.bxm). This is similar to HTML comments but adds an extra - to demarcate it as a BoxLang comment.
HTML Comment
<!-- I am an HTML Comment -->
BoxLang Comment
<!--- I am a BoxLang Comment --->Nested Tag Comments
BoxLang supports nested tag comments, which is useful when you need to comment out a block of code that already contains comments. The parser tracks the nesting depth and only closes the outer comment when all nested levels are properly terminated.
<!---
This is an outer comment
<bx:set fruit = "apple">
<!--- This is a nested comment inside --->
<bx:output>#fruit#</bx:output>
--->This feature is particularly helpful during development when you want to temporarily disable a section of code without removing existing comments.
Script Comments
If you are within a class, scripting or in a <bx:script> block, you can use an alternate style for comments. You can leverage // for single-line comments and the following for multi-line comments:
BxDoc: "Javadoc" style comments
A multi-line block can affect the metadata of a class or function if the opening line contains 2 asterisks. Also, for readability, some people will start each line of the comment with an asterisk. BoxLang will parse out those starting asterisks, but they will not appear in the class or the function metadata.
You can use all the JavaDoc style comments; however, when doing parameters, we omit the verbosity of the @param {name} hint and use the @{name} hint.
Documentation Metadata vs Standalone Annotations
It's important to understand the difference between documentation annotations (using @ inside BxDoc comments) and standalone annotations (using @ before declarations):
Documentation annotations (
@somethinginside/** */comments) become part of thedocumentationmetadata structStandalone annotations (
@somethingbefore a class/function/property) become direct metadata properties
Documentation Annotations Example:
When you call getMetadata( test ), the documentation annotations are available in the documentation struct:
Standalone Annotations Example:
These become direct annotations struct in the metadata:
CRITICAL DISTINCTION: Documentation annotations (@something inside /** */ comments) are for documentation purposes only and do NOT affect runtime behavior. They exist purely to provide metadata for documentation generators and human readers.
If you need an annotation that alters code runtime behavior (such as dependency injection, caching, validation, security, etc.), you MUST use standalone annotations (@something before the class/function/property declaration).
Flexible Annotation Syntax
BoxLang's documentation metadata system is open and flexible. You can use any @name annotation inside BxDoc comments - there are no reserved keywords or restrictions. This allows you to create custom documentation annotations tailored to your application or framework needs.
Important: Documentation annotations inside BxDoc comments (/** @annotation */) are metadata only and do NOT change runtime behavior. They are stored in the documentation metadata struct for documentation tools to read.
If you want an annotation that changes how your code executes (like @inject, @cached, @transactional), you must use first-class standalone annotations placed before the class, property, or function declaration.
Common Documentation Annotations:
Custom Documentation Annotations:
You can create your own annotations for any purpose:
All @name annotations become entries in the documentation metadata struct, accessible via getMetadata():
Simplified Parameter Documentation:
Unlike traditional JavaDoc's verbose @param name description syntax, BoxLang uses a simplified approach where you can directly use @parameterName followed by the description:
DocBox
We have a tool call DocBox that can generate the documentation off your BoxLang classes, much like JavaDoc.
Please check out the annotating your code section in the DocBox documentation to get a feel for how to document your code: https://docbox.ortusbooks.com/getting-started/annotating-your-code
Tip: VSCode has some great plugins for generating this type of documentation in your classes. We recommend the following extensions:
Align - Helps align everything
AutoCloseTag - Helps close comments as well all tags
DocumentThis - Automatically generates detailed JSDoc BoxLangDocs comments in TypeScript and JavaScript files.
Last updated
Was this helpful?

