A Payload CMS plugin that counts characters in richtext, textarea and text fields, similar to the SEO plugin character counter. Useful for editors to track content length.
- 📊 Character counting for text fields, textarea fields, and richtext fields
- 🌍 Multi-language support with translations in 40+ languages
- 🎨 Consistent styling with Payload
- ⚡ TypeScript support with full type definitions
- 🔧 Easy integration with existing Payload projects
npm install @compatis/payload-charcount
# or
yarn add @compatis/payload-charcount
# or
pnpm add @compatis/payload-charcountimport { buildConfig } from 'payload/config'
import charCountPlugin from '@compatis/payload-charcount'
export default buildConfig({
plugins: [
charCountPlugin(), // Add the plugin
],
// ... rest of your config
})import {
CharcountTextField,
CharcountTextareaField,
CharcountRichTextField,
} from '@compatis/payload-charcount/fields'
export const Posts = {
slug: 'posts',
fields: [
CharcountTextField(
{
name: 'title',
label: 'Title',
required: true,
},
{
max: 100,
min: 90,
},
),
CharcountTextareaField(
{
name: 'description',
label: 'Description',
},
{
max: 500,
min: 450,
},
),
CharcountRichTextField(
{
name: 'content',
label: 'Content',
},
{
max: 2000,
min: 1750,
},
),
],
}The field functions take two parameters:
- Field configuration - Standard Payload field properties (name, label, required, etc.)
- CharCount options - Character counting configuration
| Option | Type | Description |
|---|---|---|
max |
number |
Maximum character limit |
min |
number |
Minimum character limit |
The plugin includes translations for 40+ languages.
- Payload CMS 3.37.0+
- Node.js 18.20.2+ or 20.9.0+
- TypeScript (recommended)
If you have any questions or issues, please open an issue on GitHub.
- Optional min/max - Only one of min or max required, not both
- Hint text - Optional hint text below counter (like Payload SEO plugin)
- Word counting - Count words instead of characters
- Custom validation messages - Personalized texts
Have a feature request? Open an issue and let us know!
Special thanks to the Payload CMS team for creating such an amazing CMS and for the inspiration and translations from their SEO plugin's character counting functionality.