Articles in this section

snakecase helper

The snakecase helper converts a string to snake_case format by replacing spaces, dashes, and other non-word characters with underscores and lowercasing the result. Use it to generate consistent identifiers, database field names, or API parameters that follow underscore naming conventions.

Syntax

{{snakecase value}}

value -- The string to convert. Required. Non-string inputs (numbers, booleans) are converted to strings before processing. Arrays of primitive values are converted to a comma-separated string. Objects and object arrays produce unusable output.

Examples

Convert a mixed-separator string

{{snakecase record.product.label}}

Input:

{ "record": { "product": { "label": "a-b-c d_e" } } }

Output: a_b_c_d_e

Existing hyphens, spaces, and underscores are all normalized to a single _.

Convert a space-separated string

{{snakecase record.category}}

Input:

{ "record": { "category": "New Product Launch 2025" } }

Output: new_product_launch_2025

Split at camelCase boundaries

{{snakecase record.userAction}}

Input:

{ "record": { "userAction": "getUserProfile" } }

Output: get_user_profile

The helper inserts underscores at camelCase and PascalCase word boundaries and lowercases the result.

Usage notes

  • All word separators (spaces, dashes, and other non-word characters) are normalized to a single _.
  • Multiple consecutive separators are collapsed into a single underscore.
  • The output is always lowercased.
  • Underscores are inserted at camelCase and PascalCase boundaries.
  • Digits are preserved. Underscores are not inserted between letters and adjacent digits unless a separator already exists.
  • Do not pass objects or object arrays -- the output will be unusable.