Why This Is Useful
Here’s a complaint I’ve heard on a good handful of projects: Salesforce doesn’t tell you how many characters you have left in a text field.
You’re typing away in a Description field, you have no idea you’re approaching the limit, and in some cases Salesforce cheerfully lets you keep typing and then refuses to save. Which is genuinely infuriating when you’ve just written three paragraphs.
So I built a free, open source Character Counting Component that fixes it, and this post is about how to use it.
It’s on GitHub and it costs nothing.
What It Actually Does
It’s an enhanced page layout component. Drag it onto a record page and it looks and feels essentially like a normal page layout, except every text field shows a live character countdown as the user types.
The important design decisions:
It’s fully declarative. No code to write. Configure it in the Lightning App Builder.
It works on any object. Nothing is hardcoded. Drop it on Account, Case, your custom object, whatever.
It reads the real field limits. It uses Schema describe calls to find the actual maximum length of each field, so you don’t configure limits by hand and they can’t drift out of sync when somebody changes a field.
It works in Flows too, and on new record pages, not just record detail pages.
Setting It Up
1. Deploy it from the repo.
2. Open the Lightning record page you want it on and click Edit Page.
3. Drag the Character Counting Layout component onto the canvas.
4. Configure which fields it should display in the properties panel.
5. Save and activate.
That’s the whole thing. If you want it to replace your standard Record Detail component entirely, remove that one. If you’d rather have it alongside, showing only the long text fields users struggle with, that works fine too and is often the better call.
Why Build This Rather Than Buy One?
Partly because it’s a small enough problem that paying for a managed package felt silly. Partly because I wanted it to be something anyone could read, modify and extend.
That’s the general theme of the Open Source MVP series too. There’s an enormous amount of genuinely good free tooling in the Salesforce ecosystem, and a lot of orgs pay for things that already exist for free, mostly because nobody told them.
If you want to change how the countdown displays, or add a warning colour at 90%, go ahead. It’s your code now.
A Few Things To Know
Rich text fields behave differently. Their character count includes the underlying HTML markup, so the number won’t match what a user perceives as their visible text. That’s a Salesforce behaviour rather than something the component invents, but it surprises people.
It respects field level security. Fields the user can’t see won’t render, because it goes through standard Lightning Data Service rather than doing anything clever. As I said in the Dynamic Forms post, that’s the layer that actually enforces anything.
Don’t put a hundred fields on it. Like any component rendering a lot of fields, there’s a point where it gets sluggish. Use it for the fields where the countdown genuinely helps.
Go Grab It
It’s free, it’s open source, and it solves a small annoyance that has irritated users on basically every project I’ve worked on.
If you find a bug or want a feature, raise an issue on the repo. Pull requests welcome too.
Get Coding With The Force Merch!!
We now have a redbubble store setup so you can buy cool Coding With The Force merchandise! Please check it out! Every purchase goes to supporting the blog and YouTube channel.
Get Shirts Here!
Get Cups, Artwork, Coffee Cups, Bags, Masks and more here!
Check Out More Coding With The Force Stuff!
If you liked this post make sure to follow us on all our social media outlets to stay as up to date as possible with everything!
Youtube
Patreon
Github
Facebook
Twitter
Instagram
Salesforce Development Books I Recommend
Advanced Apex Programming
Salesforce Lightning Platform Enterprise Architecture
Mastering Salesforce DevOps
Good Non-SF Specific Development Books:
Clean Code
Clean Architecture