Lodash _.toString() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Converts value to a string. null and undefined become "". The sign of -0 is preserved. Part of Lodash 4.x Lang.

Pass the value you want to inspect or convert. Read the return type carefully before you use the result.

Syntax

Call _.toString. Start with this line.

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

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

Library declarations
Lodash
_.toString(value)

Parameters

ParameterDescription
valueRequired. Value to convert

Return Value

Return ValueDescription
*Always a string

Lodash Examples

Example 1 — Official Array

Convert a simple array to a comma-joined string.

Lodash
_.toString([1, 2, 3]);
// → "1,2,3"
Try It Yourself

How It Works

  1. Detect. Input is an array.
  2. Map. Each number becomes its string form.
  3. Join. Elements join with ",".
  4. Result. "1,2,3" — same idea as Array#toString.

Example 2 — null and undefined

Top-level nullish values become an empty string.

Lodash
_.toString(null);
// → ""

_.toString(undefined);
// → ""

String(null);
// → "null"          // native differs
Try It Yourself

How It Works

  1. Short-circuit. value == null → return "".
  2. Both. null and undefined share that path.
  3. Native. String(null) keeps the word "null".
  4. Use. Prefer Lodash when empty is safer than the word.

Example 3 — Preserve -0

Lodash keeps the negative-zero sign as text.

Lodash
_.toString(-0);
// → "-0"

String(-0);
// → "0"

(-0) + "";
// → "0"
Try It Yourself

How It Works

  1. Detect. Lodash checks 1 / value === -Infinity.
  2. Return. Literal "-0".
  3. Native. Drops the sign bit in string form.
  4. Why. Useful when the sign of zero matters in logs or serialization.

Example 4 — Symbol Without Throwing

Symbols stringify safely — no TypeError.

Lodash
_.toString(Symbol("x"));
// → "Symbol(x)"

// "" + Symbol("x");  // throws TypeError

String(Symbol("x"));
// → "Symbol(x)"      // String() also works
Try It Yourself

How It Works

  1. Detect. Lodash recognizes a Symbol.
  2. Call. Uses Symbol.prototype.toString.
  3. Safe. Avoids the + "" coercion that throws.
  4. Check. See also _.isSymbol.

Example 5 — Nested Arrays

Nesting flattens into one comma-separated string.

Lodash
_.toString([1, [2, 3]]);
// → "1,2,3"

_.toString([1, null, 3]);
// → "1,null,3"
Try It Yourself

How It Works

  1. Recurse. Nested arrays stringify from the inside out.
  2. Join. All pieces join with commas — nesting disappears.
  3. Inner null. Array elements skip the top-level "" rule → "null".
  4. Custom sep. Use _.join when you need another separator.

Browser & Runtime Support

_.toString is a Lodash 4.x Lang helper. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native cousins: String(value) and template coercion, with different nullish / −0 rules.

✓ Stable · Lodash 4.x

_.toString()

Available in [email protected] full builds and the lodash/toString 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
_.toString Lodash 4.x+

Bottom line: Safe for production once Lodash is loaded. Prefer import toString from "lodash/toString" for smaller builds. Use when you want empty nullish strings and −0 preservation.

Frequently Asked Questions

An empty string ''. Same for undefined. Native String(null) returns 'null' — Lodash differs on purpose.
Yes. _.toString(-0) returns '-0'. Native String(-0) and -0 + '' both return '0'.
Each element is stringified recursively and joined with commas — like Array.prototype.toString. Nested arrays flatten: [1,[2,3]] → '1,2,3'.
No. _.toString(Symbol('x')) returns 'Symbol(x)'. Native '' + Symbol(...) throws TypeError.
Top-level null/undefined become ''. Inside an array they stringify as 'null' / 'undefined' because array elements skip the outer nullish short-circuit.
No. Key differences: nullish → '', −0 → '-0', and Symbol-safe conversion.

Next: Lodash Math

Continue with add, ceil, floor, max, and more math helpers.

Math methods hub →

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.

9 people found this page helpful