length

Learn how to use the length function in Notion formulas.

The length() function outputs a number that corresponds to the length of a string.

length(string)
length(list)

string.length()
list.length()
Code language: JavaScript (javascript)
length("Monkey D. Luffy") /* Output: 15 */

length(["Batman", "Robin", "V", "Doctor Doom"]) /* Output: 4 */

"Supercalifragilisticexpialidocious".length() /* Output: 34 */
Code language: JavaScript (javascript)

This example database used the length() function to return the number of characters in the Name property. It also uses an if statement to intelligently output “character” or “characters”.

Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.
A new tool that blends your everyday work apps into one. It’s the all-in-one workspace for you and your team
thomasfrank.notion.site
let(
	length, prop("Name").length(),
	length 
	+ " character" 
	+ ifs(length != 1, "s")
)

/* Explained */

let(
	/* Set a length variable with the length of the Name property value */
	length, prop("Name").length(),

	/* Display the length variable */
	length 

	/* Add the " character" string */
	+ " character" 

	/* Check if the length variable does not equal 1. 
	If it doesn't, add an "s" to the end of "character" */
	+ ifs(length != 1, "s")
)
Code language: JavaScript (javascript)

This formula sets a length variable with the length of the Name property value. It then displays the value of the length variable and adds “ character” after it. Finally, if the value of length is not 0, it will add an “s” after “ character”.

Other formula components used in this example:

if – Thomas Frank
thomasjfrank.com
format – Thomas Frank
thomasjfrank.com
add – Thomas Frank
thomasjfrank.com
About the Author

My name is Thomas Frank, and I'm a Notion-certified writer, YouTuber, and template creator. I've been using Notion since 2018 to organize my personal life and to run my business and YouTube channel. In addition to this formula reference, I've created a free Notion course for beginners and several productivity-focused Notion templates. If you'd like to connect, follow me on Twitter.

🤔 Have an UB Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas

🤔 Have a Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas