Lodash _.isString() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Checks if value is classified as a string primitive or String object. Part of Lodash Lang since 0.1.0 (stable — not deprecated).

Note: Empty "" still counts as a string. Prefer string primitives in new code; boxed new String(...) is rare.

Syntax

Call _.isString. Start with this line.

Lodash
_.isString(value)
CallWhat it does
_.isString(value)Primary signature.

Prefer import isString from "lodash/isString" when you want a smaller bundle.

Library declarations
Lodash
_.isString(value)

Parameters

ParameterDescription
valueRequired. The value to check

Return Value

Return ValueDescription
*true if string, else false

Lodash Examples

Example 1 — Official: 'abc'

A string primitive is classified as a string.

Lodash
_.isString('abc');
// → true
Try It Yourself

How It Works

  1. Input. Official sample: the primitive 'abc'.
  2. Type. typeof 'abc' === "string".
  3. Result. Returns true.
  4. Use. Guard text fields before calling string methods.

Example 2 — Official: Number 1

Numbers are not strings — even when they look like text.

Lodash
_.isString(1);
// → false
Try It Yourself

How It Works

  1. Input. The number 1 from the official docs.
  2. Wrong type. It is a number, not text.
  3. Result. Returns false.
  4. Tip. Use '1' or String(1) when you need a string.

Example 3 — Empty String

Blank text is still a string — falsy, but typed correctly.

Lodash
_.isString('');
// → true

_.isString(' ');
// → true
Try It Yourself

How It Works

  1. Empty. "" has type string.
  2. Whitespace. A space is also a string.
  3. Both pass. Type check ≠ “has content?”.
  4. Validate. Use .trim().length when blanks are invalid.

Example 4 — Boxed String Object

Lodash also accepts new String(...); typeof alone does not.

Lodash
var boxed = new String('abc');

_.isString(boxed);           // → true
typeof boxed === "string";   // → false  (typeof is "object")
Try It Yourself

How It Works

  1. Boxed. new String('abc') is a String object.
  2. isString. Lodash classifies it as string → true.
  3. typeof. Reports "object" → fails a naive check.
  4. Prefer. Use primitives ('abc') in new code.

Example 5 — Common Non-Strings

Values that often show up near text fields but are not strings.

Lodash
_.isString(null);       // → false
_.isString(true);       // → false
_.isString(['a']);      // → false
_.isString(undefined);  // → false
Try It Yourself

How It Works

  1. nullish. Use _.isNil for missing values.
  2. Boolean. Use _.isBoolean.
  3. Array. One-element arrays are still arrays.
  4. Rule. Only string-branded values pass.

Browser & Runtime Support

_.isString is a Lodash Lang helper (available since 0.1.0, stable in 4.x). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 0.1.0+

_.isString()

Available in [email protected] full builds and the lodash/isString modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.isString Lodash 0.1.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import isString from "lodash/isString" for smaller builds. For primitives only, typeof value === "string" is enough.

Frequently Asked Questions

_.isString(value) returns true if value is a string primitive or a boxed String object. Numbers, booleans, null, arrays, and other types return false.
Yes. "" is still a valid string. Combine with a length check if you also require non-empty input.
Boxed String objects have typeof "object", but Lodash recognizes the [object String] brand and returns true — matching the docs intent for string classification.
typeof only catches primitives. _.isString also accepts rare String objects. Prefer primitives in new code; use _.isString when you must accept both.
Template literals evaluate to plain strings, so _.isString(`hi`) returns true.
Use import isString from "lodash/isString" or require("lodash/isString"). Full build: import _ from "lodash" then _.isString.

Next: _.isSymbol()

Check whether a value is classified as a Symbol.

_.isSymbol() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful