isBlank
Checks if a string is blank — empty or contains only whitespace characters.
null and undefined are considered blank and return true.
Uses String.prototype.trim() internally, which covers all ECMAScript
whitespace: standard ASCII whitespace (\t, \n, \r, \f, \v),
non-breaking space (U+00A0), BOM (U+FEFF), and all Unicode “Space_Separator”
category characters (en space, em space, thin space, ideographic space, etc.).
Zero-width characters (U+200B zero-width space, U+200C, U+200D, U+2060)
are not treated as whitespace — they are Unicode “Format” (Cf) characters,
not spaces. Strip them explicitly if needed:
isBlank(value.replace(/[-]/g, ''))
Available since v2.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | null | undefined | The string to check |
Returns
Section titled “Returns”boolean — true if the string is empty, contains only whitespace, or is null/undefined
Examples
Section titled “Examples”Detect empty or whitespace-only strings
Section titled “Detect empty or whitespace-only strings”Returns true for "" and for any string made entirely of whitespace — including non-breaking space (U+00A0), en/em spaces, ideographic space, and BOM.
Form validation — reject blank input
Section titled “Form validation — reject blank input”Use isBlank to reject fields that contain only whitespace.
