# 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.
1
length(string)

## Example Formulas

1
length("Monkey D. Luffy") // Output: 15
2
3
length("Supercalifragilisticexpialidocious") // Output: 34
4
5
length("Doctor Doom") // Output: 11

## Example Database

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”.

### “Characters” Property Formula

1
// Compressed
2
format(length(prop("Name"))) + " " + ((length(prop("Name")) == 1) ? "character" : "characters")
3
4
// Expanded
5
format(
6
length(prop("Name"))
7
) +
8
" " +
9
(
10
(
11
length(
12
prop("Name")
13
) == 1
14
) ?
15
"character" :
16
"characters"
17
)
This formula first uses the `length()` function to get the number of characters in the Name property. This is wrapped in the format function in order to convert the number to a string.
Second, an if statement again uses `length()` to check whether or not the number of characters in the Name property is equal to `1`. If so, it outputs the singular “character”. If not, it outputs the plural “characters.”