toSnakeCaseKeys es-toolkit
Returns a new object with all keys in objects and arrays converted to snake_case.
Snake case is a naming convention where each word in an identifier is written in lowercase and connected with underscores (_). For example, it's written as snake_case.
Usage
toSnakeCaseKeys(obj)
Use toSnakeCaseKeys when you want to convert all keys of an object to snake_case. Nested objects and objects within arrays are also converted recursively.
For example, object keys are converted as follows:
camelCase→snake_case(e.g.userId→user_id)PascalCase→snake_case(e.g.UserId→user_id)UPPERCASE_KEYS→snake_case(e.g.FIRST_NAME→first_name,LAST→last)
Parameters
The object, array, or primitive value to convert keys to snake_case.
Returns
Returns a new object with all keys converted to snake_case.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.