Lodash String Methods

About This Index
This page is the Lodash String index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
Learn chaining on /lodash/seq. Use this page when you need string helpers such as _.camelCase(), _.trim(), or _.escape().
Start with _.camelCase(), then _.trim(), _.escape(), and _.truncate()—then browse case and template helpers.
How to Call a String Method
Pass a string (and any options) to the Lodash helper—results are new values:
import _ from "lodash";
_.camelCase("Foo Bar"); // "fooBar"
_.kebabCase("fooBar"); // "foo-bar"
_.snakeCase("fooBar"); // "foo_bar"
_.startCase("--foo-bar--"); // "Foo Bar"
_.trim(" hello "); // "hello"
_.padStart("5", 3, "0"); // "005"
_.truncate("hi-diddly-ho", { length: 10 }); // "hi-didd..."
_.escape("<div>"); // "<div>"
_.words("fred, barney, & pebbles");
// ["fred", "barney", "pebbles"] Lodash String Methods Table
All string method guides in this Lodash tutorial series (30 tutorials).
Case Conversion
11 methodscamelCase, kebab-case, snake_case, Start Case, and first-letter helpers.
| Method | Description | Tutorial |
|---|---|---|
_.camelCase() | Convert a string to camelCase (e.g. "foo bar" → "fooBar"). | Try it |
_.capitalize() | Uppercase the first character and lowercase the rest. | Try it |
_.kebabCase() | Convert a string to kebab-case (e.g. "fooBar" → "foo-bar"). | Try it |
_.snakeCase() | Convert a string to snake_case (e.g. "fooBar" → "foo_bar"). | Try it |
_.startCase() | Convert to Start Case with capitalized words. | Try it |
_.lowerCase() | Convert a string to space-separated lower case (Lodash word rules). | Try it |
_.upperCase() | Convert a string to space-separated upper case (Lodash word rules). | Try it |
_.toLower() | Convert the entire string to lower case. | Try it |
_.toUpper() | Convert the entire string to upper case. | Try it |
_.lowerFirst() | Lowercase only the first character of the string. | Try it |
_.upperFirst() | Uppercase only the first character of the string. | Try it |
Trim & Pad
6 methodsTrim edges and pad strings to a target length.
| Method | Description | Tutorial |
|---|---|---|
_.trim() | Remove leading and trailing whitespace (or custom chars). | Try it |
_.trimStart() | Remove leading whitespace (or custom chars). | Try it |
_.trimEnd() | Remove trailing whitespace (or custom chars). | Try it |
_.pad() | Pad a string on left and right to a target length. | Try it |
_.padStart() | Pad the start of a string to a target length. | Try it |
_.padEnd() | Pad the end of a string to a target length. | Try it |
Escape & Template
4 methodsHTML and RegExp escaping, unescape, and templates.
| Method | Description | Tutorial |
|---|---|---|
_.escape() | Escape HTML special characters (&, <, >, ", ') for safe text output. | Try it |
_.unescape() | Reverse HTML entity escaping from _.escape(). | Try it |
_.escapeRegExp() | Escape RegExp metacharacters so a string can be used literally. | Try it |
_.template() | Compile a template string with interpolate, escape, and evaluate tags. | Try it |
Search, Split & Shape
9 methodsStarts/ends checks, replace, split, words, truncate, repeat, and parseInt.
| Method | Description | Tutorial |
|---|---|---|
_.startsWith() | Return true if the string starts with the given target. | Try it |
_.endsWith() | Return true if the string ends with the given target. | Try it |
_.replace() | Replace matches in a string. | Try it |
_.split() | Split a string into an array by separator. | Try it |
_.words() | Split a string into an array of words using Lodash word rules. | Try it |
_.truncate() | Truncate a string with an omission when longer than a length limit. | Try it |
_.repeat() | Repeat a string n times. | Try it |
_.parseInt() | Parse an integer from a string with consistent radix handling. | Try it |
_.deburr() | Remove combining diacritical marks (Latin letters). | Try it |
Frequently Asked Questions
Start with _.camelCase()
Open the case conversion guide—syntax, examples, and FAQs.
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.
14 people found this page helpful
