Notion Formula Length(): Character Count vs Word Count
🔍 WiseChecker

Notion Formula Length(): Character Count vs Word Count

Notion formulas can count text in two ways: characters and words. The length() function returns the number of characters in a string, including spaces and punctuation. Many users assume it counts words, which leads to incorrect results in databases, task trackers, or content summaries. This article explains the difference between character count and word count in Notion formulas, shows how to build a word count formula from scratch, and covers common pitfalls to avoid when measuring text length.

Key Takeaways: Character Count vs Word Count in Notion Formulas

  • length(prop("Text")): Returns the total number of characters, including spaces and punctuation. Not a word count.
  • Word count formula using replaceAll() and length(): Counts words by removing extra spaces and measuring remaining segments.
  • prop("Text").length(): Alternative syntax that produces the same character count as the standard length() function.

How Notion’s length() Function Counts Characters

The length() function in Notion formulas returns the number of characters in a string. A character is any single unit of text: letters, digits, spaces, punctuation marks, and special symbols. For example, the string “Hello World” contains 11 characters because the space between the two words counts as one character. Notion does not provide a built-in word count function. Every formula that counts words must be constructed manually using string manipulation functions such as replaceAll(), slice(), and nested length() calls.

The character count includes leading and trailing spaces if they exist. A string like ” apple ” (with one leading space and one trailing space) returns 7 characters, not 5. This behavior often surprises users who expect length() to return only visible characters. Notion also counts newline characters as one character each. If you copy text from a multi-line source, the line breaks increase the character count.

When Character Count Is the Right Tool

Character count is useful for validation rules, such as limiting a property to a maximum number of characters for a Twitter-style bio or a short description. It is also used in formulas that calculate reading time or estimate storage size. If your goal is to enforce a strict character limit, length() is the correct function.

When Character Count Fails

Character count fails when you need to count words. A database that tracks the number of words in a meeting note, a blog post draft, or a customer feedback entry cannot use length() alone. The character count for a 100-word paragraph varies depending on word length, so it does not represent the word count.

Building a Word Count Formula in Notion

To count words, you must remove all extra spaces and then count the remaining space-separated segments. The standard approach uses replaceAll() to collapse multiple spaces into a single space, trim leading and trailing spaces, and then count the spaces plus one. The formula below assumes your text is in a property called Text.

  1. Create a formula property
    Add a new property to your database. Set the type to Formula. Name it Word Count or similar.
  2. Enter the word count formula
    Paste the following formula into the formula editor:
    length(replaceAll(trim(prop("Text")), " +", " ")) - length(replaceAll(trim(prop("Text")), "[^ ]", "")) + 1
    This formula works by counting the number of spaces in the trimmed text and adding one to get the word count.
  3. Test the formula
    Enter a short sentence in the Text property, such as “Notion formulas are powerful.” The formula should return 4. If the property is empty, the formula will return 1 because the space count formula still adds one. To handle empty properties, wrap the entire formula in an if() statement:
    if(empty(prop("Text")), 0, length(replaceAll(trim(prop("Text")), " +", " ")) - length(replaceAll(trim(prop("Text")), "[^ ]", "")) + 1)
  4. Verify with edge cases
    Test with a single word (returns 1), with multiple spaces between words (returns correct count), and with leading/trailing spaces (returns correct count after trimming).

Alternative Word Count Formula Using slice() and test()

Some users prefer a formula that counts words by iterating over each character. This approach is more complex and less efficient. The space-count method above is the most reliable and widely used in the Notion community.

Common Mistakes When Counting Characters and Words

Word Count Formula Returns 1 for Empty Properties

The base formula without the if() wrapper returns 1 when the text property is empty because it counts zero spaces and adds one. Always wrap the formula with if(empty(prop("Text")), 0, ...) to return 0 for empty cells.

Character Count Includes Spaces in Unexpected Places

Users often paste text from web pages or documents that contain non-breaking spaces or tab characters. Notion treats these as normal characters. If your character count seems off, check for invisible characters. Use replaceAll(prop("Text"), "[^a-zA-Z0-9]", "") to count only letters and digits if you need an alphanumeric count.

Word Count Formula Fails with Punctuation Attached to Words

The formula above counts words separated by spaces. If a word is followed by a period without a space (like “powerful.”), the period is part of the word segment. The word count remains correct because the period does not create an extra space. However, if you need to count only alphabetic words, you must first remove punctuation with an additional replaceAll() step.

Using prop("Text").length() Instead of length(prop("Text"))

Notion supports dot notation for some functions. Both prop("Text").length() and length(prop("Text")) return the same character count. The dot notation is shorter but may be less readable for complex formulas. Choose one style and use it consistently.

Character Count vs Word Count: Formula Behavior Compared

Item Character Count (length()) Word Count (custom formula)
Counts spaces Yes No (spaces are separators, not words)
Counts punctuation Yes Yes (attached to words)
Counts newlines Yes No (newlines are ignored unless replaced with spaces)
Empty property returns 0 0 (with if() wrapper)
Single word returns Length of that word 1
Multiple spaces between words Counts each space Correct word count after trimming

Notion’s length() function is a character counter, not a word counter. To count words in a Notion database, you must build a formula using replaceAll(), trim(), and length(). The space-count method is the most efficient and reliable. Always handle empty properties with an if() statement to avoid returning 1 instead of 0. For advanced use cases, such as counting only alphabetic words or excluding punctuation, add extra replaceAll() steps before the word count calculation. Test your formula with edge cases including empty cells, single words, and text with irregular spacing to ensure accuracy.