JavaScript String length
Example
Return the number of characters in a string:
let str = "Hello World!";
str.length // Returns 12
Try it Yourself »
Definition and Usage
The length property returns the length of a string.
The length of an empty string is 0.
Browser Support
length is fully supported in all browsers:
| Chrome | IE | Edge | Firefox | Safari | Opera |
| Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
string.length
Technical Details
| Return Value: | The length of a string |
|---|---|
| JavaScript Version: | 1.0 |

