str length for strings
Output the length of any strings in the pipeline.
Signature
> str length {flags} ...rest
Flags
-
--grapheme-clusters, -g: Count length in grapheme clusters (all visible chars have length 1). -
--utf-8-bytes, -b: Count length in UTF-8 bytes (default; all non-ASCII chars have length 2+). -
--chars, -c: Count length in chars.
Parameters
-
...rest: For a data structure input, replace strings at the given cell paths with their length.
Input/output types:
| input | output |
|---|---|
| string | int |
| list<string> | list<int> |
| table | table |
| record | record |
Examples
Return the lengths of a string in bytes.
> 'hello' | str length 5
Count length of a string in grapheme clusters.
> '🇯🇵ほげ ふが ぴよ' | str length --grapheme-clusters 9
Return the lengths of multiple strings in bytes.
> ['hi' 'there'] | str length ╭───┬───╮ │ 0 │ 2 │ │ 1 │ 5 │ ╰───┴───╯
Return the lengths of a string in chars.
> 'hällo' | str length --chars 5
Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/str_length.html