Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE

Create Cleaner, More Readable Code With Clarinet’s New Clarity Formatter

Ever struggle to read your own code or hate spending time making it more readable for your coworker? We’ve launched a new code formatter in Clarinet, so your Clarity code is easy to read and easier to maintain.

Type
Product update
Topic(s)
Product
Published
February 20, 2025
Author(s)
Sr. Software Engineer
A graphic showing highlighted Clarity code
Contents

Clarity is a double-edged sword for devs in Stacks. On the one hand, it’s a language perfectly designed for the realities of smart contracts. It’s human-readable, open source code for every contract is available on the blockchain, and the language is decidable. In other words, Clarity is transparent and secure, just like you want a smart contract to be.

But on the other hand, you have to learn this language, which can be a point of friction in the beginning of your development journey on Stacks. With a new Clarity formatter in Clarinet, development just got a whole lot easier.

Cleaner, More Readable Code

With a new Clarity formatter in Clarinet, any code you generate will be auto-formatted, instantly making your code clean, readable, and easier to maintain.

Here’s an example of what unformatted code looks like:

And here’s what that same sample looks like afterwards:

No more fussing with your code’s formatting or wondering how to format it in the first place. Instead you can focus on what matters: writing the code that powers your application. Clarinet will handle the rest.

Note: this feature is currently in beta and only available in the CLI. We will be adding formatting support to the VSCode integration soon.

If you have any feedback about the formatter, please add your thoughts to this GitHub issue or reach out to us on the #clarinet channel under the Hiro Developer Tool section on the Stacks Discord.

We plan on incorporating your feedback into how the formatter works in future releases. In the meantime, if you’re unhappy with the formatting it produces you can also ignore the formatter for blocks of code with <code-rich-text>;;@format-ignore<code-rich-text>.

Happy coding!

Product updates & dev resources straight to your inbox
Your Email is in an invalid format
Checkbox is required.
Thanks for
subscribing.
Oops! Something went wrong while submitting the form.
Copy link
Mailbox
Hiro news & product updates straight to your inbox
Only relevant communications. We promise we won’t spam.

Related stories