lower turns every letter of a string into lowercase. Comparing two values after lower treats Tea and TEA as the same name.
Syntax
Syntax
lower(<STRING>)
<STRING>: the text to convert. Letters with accents are converted too; digits and other characters stay as they are.
The docs say it converts all cased letters: lower Function.
Prerequisites
- OpenTofu® installed. Installing OpenTofu in the OpenTofu docs covers every system.
Step 1: Try It in tofu console
Open a terminal in any empty folder and start tofu console, which evaluates expressions as you type them:
Terminal
tofu console
Type each expression to see the result:
tofu console
> lower("HELLO World")
"hello world"
> lower("ÉCOLE")
"école"
> lower("Tea") == lower("TEA")
true
> exit
Clean Up
Type exit to leave the console. The example creates nothing, so there’s nothing else to remove.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Expecting it to change the variable | It returns a new string; the original value is unchanged. | Use the result where you need it. |
| Comparing names without it | "Tea" == "TEA" is false. | Compare lower(a) == lower(b). |
FAQ
Is there an uppercase version?
Yes, the upper function does the opposite.
Does lower change accented letters?
Yes: lower("ÉCOLE") returned "école" above.
Conclusion
lower(<STRING>) returns the string in lowercase, which makes comparisons ignore case.
Additional Resources
OpenTofu® is a registered trademark of LF Projects, LLC. Other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by the OpenTofu project.
