If you observe the license conditions that can be found on the respective website, you can of course use the tools for commercial purposes. There are no code size limitations or similar. See e.g. the license agreement at the bottom of the website of STM32CubeIDE (SLA0048 applies for almost all software tools).
Good luck!
If the problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.
/Peter
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.